Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to I get input text from a text box?

Asked by 4 years ago

I'm making an admin panel where you can give or take away points from a player by putting their username and the amount in a text box and then it takes those inputs to set player value, but it's not taking the text. Here's the script:

script.Parent.MouseButton1Click:Connect(function()
    local player = script.Parent.Parent.To.Text
    local amount = script.Parent.Parent.Amount.Text
    game.Players[player].rep.Value = amount
end)

that's just one of them but the rest don't work either and I'm pretty sure if I can get this one fixed I can fix them all. The text values just come back as nothing, and I proved this by putting print(player, amount) and it just came up as nothing and it gives the error " is not a valid member of Players". how do i fix this?

0
This wouldn't work regardless due to FE. Ziffixture 6913 — 4y
0
You have to use this on the client because the text wont apply on the server. Use a localscript with this code, but then fire a remote event with the arguments to the server to cause the point loss pengalu200 65 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

You will have to use remote events for this as textbox text is client only. Local script:

game.ReplicatedStorage.RemoteEvent:FireServer(script.Parent.Parent.TextBox.Text)

script:

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr, text) --Text will be the textbox's text.

Hope this helped!!

Ad

Answer this question