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

How to allow the server to access a TextBox in StarterGui?

Asked by 4 years ago

Hi, I'm trying to make a system where when the player touches a brick, a gui pops up prompting them to put in text. When they type in the text and hit the "Finish" button it changes the value of a StringValue inside of ReplicatedStorage. Only problem is, is that the value always changes to "Text" instead of what the player puts in because that's what the default text to the TextBox is. If anybody could help me that would be greatly appreciated! Thanks

Server Script:

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        for i,v in pairs(game.Players:GetPlayers()) do
            local Player = v
            if Player.Name == hit.Parent.Name then
                game.ReplicatedStorage.SendText:FireClient(Player)
            end
        end
    end
end)

game.ReplicatedStorage.ReceiveText.OnServerEvent:Connect(function(player, Box)
    game.Workspace.TextPart.SurfaceGui.TextLabel.Text = Box.Text
end) 

Local Script:

game.ReplicatedStorage.SendText.OnClientEvent:Connect(function()
    script.Parent.TextBox.Visible = true
    script.Parent.TextButton.Visible = true
    script.Parent.TextButton.MouseButton1Click:Connect(function()
        script.Parent.TextBox.Visible = false
        script.Parent.TextButton.Visible = false
        game.ReplicatedStorage.ReceiveText:FireServer(game.StarterGui.ScreenGui.TextBox)
    end)
end)

Answer this question