There are a few things you’ll want to change here.
PlayerAdded runs when a player joins the game, not when their character loads in. You’ll want to do this:
game.Players.PlayerAdded:Connect(function(Player)
--Player has joined the game
Player.CharacterAdded:Connect(function(Character)
--Player's Character has spawned
end)
end)
What you have to check the badge is fine, so let’s add that in.
game.Players.PlayerAdded:Connect(function(Player)
--Player has joined the game
Player.CharacterAdded:Connect(function(Character)
--Player's Character has spawned
if BadgeService:UserHasBadgeAsync(Player.UserId, 2124633610) then
end
end)
end)
Next, instead of doing sparkles.Parent = player.Torso
, you need to do sparkles:Clone().Parent = player.Character.PrimaryPart
. The :Clone()
makes a copy of the sparkles, so we can give it to the player. If you don’t put :Clone()
, you’ll give away the only copy of the sparkle effect and you’ll get an error if a second person joins or the first player dies and respawns. Players are the people themselves, Characters are the avatars running around ingame. R6 and R15 characters have differently named parts. Replacing “Torso” with “PrimaryPart” ensures that all players can get the effect.
game.Players.PlayerAdded:Connect(function(Player)
--Player has joined the game
Player.CharacterAdded:Connect(function(Character)
--Player's Character has spawned
if BadgeService:UserHasBadgeAsync(Player.UserId, 2124633610) then
sparkles:Clone().Parent = Character.PrimaryPart
end
end)
end)