PlayerAdded repeat

Im tryna push PlayerAdded for respawning.

Problem is PlayerAdded work only one time, but it doesn’t repeat which i want.

Script

local Players = game:GetService(“Players”)

function player(Spawn)
wait(1)

Spawn.PlayerGui.b.Enabled = true

end

while true do
wait()
player()
end

Players.PlayerAdded:Connect(player)

1 Like

You haven’t really specified what you’re trying to do here, and also what the issue is.

It’s hard to help you without these details :confused:

Are you trying to make the player respawn every time player spawns in? Use CharacterAdded then. And if you’re trying to make the PlayerAdded function respawns the player then do player:LoadCharacter()

Other than that, I really couldn’t identify your problem or error here. Put in more details.

Your thread is extremely unclear, as is your code. Please refer to our category guidelines for more information about posting to this category. You should be as detailed as possible about your problem, one-liner threads aren’t sufficient enough to convey anything.

PlayerAdded isn’t meant to be repeated, it’s an event which gets fired every time a player joins. Your while loop is preventing the PlayerAdded connection line from being reached because it doesn’t terminate. No code after a while loop runs unless it terminates. Furthermore, you should not be controlling PlayerGuis through the server. This is all work you can do straight from the client.

2 Likes

What exactly are you trying to achieve? Your post is unclear.

If you want something to happen every time someone respawns, use the CharacterAdded function

This is the one , Thank you and i couldn’t explain alots about my project. I’m glad you support this post.

1 Like