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

How would i make this work everytime the player respawns?

Asked by 8 years ago

I have this script

game:GetService('Players').PlayerAdded:connect(function(player)
if player:FindFirstChild("Points") ~= nil then
if player.Points.Value > 0 and player.Points.Value <= 40 then
player.leaderstats.Rank.Value = "Private"
elseif player.Points.Value > 40 and player.Points.Value <= 100 then
player.leaderstats.Rank.Value = "General"
end
end
end)

but it only works when the player enters the game for the first time, so how would I make it work everytime the player respawns?

1 answer

Log in to vote
3
Answered by
xuefei123 214 Moderation Voter
8 years ago

You would need to use the function built into the player, .CharacterAdded, here is an example:

game:GetService('Players').PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function()--Added function
if player:FindFirstChild("Points") ~= nil then
if player.Points.Value > 0 and player.Points.Value <= 40 then
player.leaderstats.Rank.Value = "Private"
elseif player.Points.Value > 40 and player.Points.Value <= 100 then
player.leaderstats.Rank.Value = "General"
end)--Added end
end
end
end)

This should work, if it does, or helps you, could you accept the answer? It gives us both rep!

Ad

Answer this question