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

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

Asked by 6 years ago
Edited 6 years ago

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

Log in to vote
0
Answered by
RayCurse 1518 Moderation Voter
6 years ago
Edited 6 years ago

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)

0
Thank you very much! BelgiumStorage 3 — 6y
Ad

Answer this question