I’ve been trying to figure this out for about 30 minutes and have had no luck. I’m stumped and cannot figure this out.
I am trying to make a script that allows the player to change their money by inputting a number into their TextBox.
Local Script (child of TextBox)
script.Parent.FocusLost:Connect(function(enter) if enter then -- this is to check the player's input local finalvalue = tonumber(script.Parent.Text) print(script.Parent.Text) -- if it was not a number if finalvalue == nil then script.Parent.Text = "Not a number" wait(1) -- just making sure that it doesn't delete the player's new input if script.Parent.Text == "Not a number" then script.Parent.Text = "" end else -- firing the money remote event with the finalvalue variable game.ReplicatedStorage.ChangeMoney:FireServer(finalvalue) print("fired") -- resetting the textbox script.Parent.Text = "" end end end)
Server Script (child of ServerScriptService)
game.ReplicatedStorage.ChangeMoney.OnServerEvent:Connect(function(amt) game.ReplicatedStorage.Money.Value = tonumber(amt) print("money changed to " .. tostring(amt)) end)
The problem is that
OnServerEvent receives a
Player in addition to a tuple of arguments passed by
It looks like there is just one money value for the entire server, so assuming that the value you’re trying to change is independent of the player who sent the
RemoteEvent, you can just change your function declaration to accept the
Player and just disregard it after that: