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

I'm having trouble with PlayerAdded and CharacterAdded?

I'm trying to make a text button local script that fires a remote event for a server script to disable a billboard GUI that is in a player's head. Nothing happens when I click the text button.

Text button script:

script.Parent.MouseButton1Click:Connect(function()
	game.ReplicatedStorage.RemoteEvent:FireServer()
end)

Server Script:

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player)
		game.Players.PlayerAdded:Connect(function(Player)
		Player.CharacterAdded:Connect(function(Character)
			local Head = Character.Head
			Head.OverheadGui.Enabled = false
			Head.OverheadPlayerGui.Enabled = false
		end)
	end)
 end)

Any help appreciated, thanks.

1 answer

✓ Accepted answer

Hello, HypedNebula!

In this case, there is no reason to use the PlayerAdded event. Below you can see an example script that can hopefully fix your issue. It's just like yours but I removed a few things.

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player)
	if workspace:WaitForChild(player.Name) then
	    local Head = workspace[player.Name].Head
	    Head.OverheadGui.Enabled = false
	    Head.OverheadPlayerGui.Enabled = false
	end
 end)

1 comment

0

Thank you!

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