Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

The answer to my earlier question didn't work?

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.

5 comments

0

what does the error message say?

0

Gui is not a valid member of PlayerGui

0

What are you trying to accomplish btw, I think I know the answer

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.

0

You can't fire server events from local script. Try firing FireClient instead.

2 answers

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)

4 comments

0

It didn't work?

0

'LocalPlayers is not a valid member of Players' was the error message

0

It's a type... Replace it with game.Players.LocalPlayer

0

typo*

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!

3 comments

0

It said Gui is not a valid member of StarterGui

0

What is the ScreenGui's name?

0

ScreenGui

This discussion is preserved as it was. New answers, comments, and votes are closed.