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

The answer to my earlier question didn't work?

Asked by 4 years ago

I tried using the code from earlier to try and fix my problem, but it didn't work! Here are all the code snippets:

ServerScriptService script:

game.ReplicatedStorage.InfoInput.OnServerEvent:Connect(function(player)
    workspace.Board.SurfaceGui.Username.Text = player.PlayerGui.Gui.ScreenGui.Frame.Username.Text
end)

TextButton [Local] script:

script.Parent.MouseButton1Click:Connect(function()
    print("Clicked!")
    local TextBox = game.StarterGui.ScreenGui.Frame.Username
    game.ReplicatedStorage.InfoInput:FireServer(TextBox.Text)
end)

I have already asked someone for help and they said to make some changes to the TextButton script? I don't know if I'm being really dumb, or it just doesn't work.

0
what does the error message say? BringingChaos 35 — 4y
0
Gui is not a valid member of PlayerGui theepicboy6789 56 — 4y
0
What are you trying to accomplish btw, I think I know the answer TheBigBro122 427 — 4y
0
I'm trying to make a surface gui textlabel's text the same as a text box's user input text when a button is pressed. theepicboy6789 56 — 4y
0
You can't fire server events from local script. Try firing FireClient instead. PrismaticFruits 842 — 4y

2 answers

Log in to vote
1
Answered by 4 years ago

This is for the ServerScriptService Script

--ServerScriptService Script

game.ReplicatedStorage.InfoInput.OnServerEvent:Connect(function(player, text)
    --The "text" variable is the TextLabel's text that the LocalScript is passing, and change
    workspace.Board.SurfaceGui.Username.Text = text
end)

This is for the LocalScript

--LocalScript

local player = game.Players.LocalPlayers --Gets the player that the localscript is in

script.Parent.MouseButton1Click:Connect(function()
    print("Clicked!")
    --Gets the TextBox from the player's gui
    local TextBox = player.PlayerGui.ScreenGui.Frame.Username

    --Sends the text to the Server via RemoteEvent
    game.ReplicatedStorage.InfoInput:FireServer(TextBox.Text)
end)
0
It didn't work? theepicboy6789 56 — 4y
0
'LocalPlayers is not a valid member of Players' was the error message theepicboy6789 56 — 4y
0
It's a type... Replace it with game.Players.LocalPlayer TheBigBro122 427 — 4y
0
typo* TheBigBro122 427 — 4y
Ad
Log in to vote
0
Answered by
AlphaY7 -3
4 years ago

The ServerScriptService script should say this:

game.ReplicatedStorage.InfoInput.OnServerEvent:Connect(function(player)
        workspace.Board.SurfaceGui.Username.Text =--Next line goes here game:GetService("StarterGui").Gui.ScreenGui.Frame.Username.Text 
    end)

If there are any errors let me know!

0
It said Gui is not a valid member of StarterGui theepicboy6789 56 — 4y
0
What is the ScreenGui's name? AlphaY7 -3 — 4y
0
ScreenGui theepicboy6789 56 — 4y

Answer this question