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

[FE] Why is my GUI giving me an error that my Sign isn't a valid member of Player?

I'm trying to make a sign that puts text on it after you type it into a GUI. The GUI comes up after the tool is equipped.

For some reason I am getting an error. I've added :WaitForChild() and repeat wait() until seeing if maybe it wasn't recognizing that its there.

17:22:36.263 - SignTool is not a valid member of Player

17:22:36.263 - Stack Begin

17:22:36.264 - Script 'ServerScriptService.Script', Line 3

17:22:36.265 - Stack End

LocalScript

local Message = script.Parent.Parent.TextBox
local Player = game.Players.LocalPlayer.Character

script.Parent.MouseButton1Click:connect(function()
	game.ReplicatedStorage.ChangeText:FireServer(Player, Message)
end)

Script

game.ReplicatedStorage.ChangeText.OnServerEvent:connect(function(Player, Message)
	Player.SignTool.Sign.SurfaceGui.TextLabel.Text = Message.Text
end)

1 answer

✓ Accepted answer

Your server script is the one that is causing the error. The OnServerEvent of the RemoteEvent returns the player instance that fired the event by default. There is no need to send the player through the remote event because it is done automatically. This is how the fix would look like:

Local Script:

local Message = script.Parent.Parent.TextBox
 
script.Parent.MouseButton1Click:Connect(function()
	--Player is sent by default so there is no need to put it in the
	--args
	game.ReplicatedStorage.ChangeText:FireServer(Message)
end)

Server Script:

game.ReplicatedStorage.ChangeText.OnServerEvent:Connect(function(Player, Message)
	local Character = Player.Character or Player.CharacterAdded:wait()
	Character.SignTool.Sign.SurfaceGui.TextLabel.Text = Message.Text
end)

1 comment

0

Thank you very much!

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