I’m trying to make a GUI that when you click a button it sets a Value in the workspace to your username and then makes a GUI frame visible. Everything I’ve tried so far doesn’t work, I’ll pop the scripts below.
BUTTON SCRIPT
script.Parent.MouseButton1Click:Connect(function(Player)
if game.Workspace.HostValue.Value == "None" then
game.Workspace.HostValue.Value = Player.Name
game.ReplicatedStorage.HostEvent:FireClient(Player)
end
end)
GUI FRAME SCRIPT
local Event = game.ReplicatedStorage.HostEvent
Event.OnClientEvent:Connect(function(player)
script.Parent.Visible = false
end)
Last time I did something like this, I got the same error. Its because MouseButton1Click doesn’t work like PlayerAdded. PlayerAdded gives a player value, I’m not sure how MouseClick works but I do know you cannot get a player from that function, try getting the localplayers name. It’s a client script so just do game.Players.LocalPlayer.Name… etc. I also don’t see why you need a remote for this.