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

Script updates every server. Another way to update every time the player joins?

Hello, could anyone help me? This script only updates every new server. I heard that with GroupService it will update everytime the player joined but I don't know how to use GroupService. I've looked on the wiki but still don't understand.

This is the script:

local plrServ = game:GetService('Players')

script.Parent.Touched:connect(function(hit)
    local plr = plrServ:GetPlayerFromCharacter(hit.Parent)
    if plr and plr:GetRankInGroup(3200799) < 30 then
        plr:LoadCharacter()
    end
end)

script.Parent.Touched:connect(function(hit)
    local plr = plrServ:GetPlayerFromCharacter(hit.Parent)
    if plr and plr:GetRankInGroup(3200799) == 31 then
        plr:LoadCharacter()
    end
end)

Example: Player3's rank is suspended. He gets his old rank back. He joins the server (an old server where he had his suspended rank too) but gets respawned every time because the script didn't update.

1 answer

Try too use a PlayerAdded function like this:

game.Players.PlayerAdded:Connect(player) --player parameter

--stuff in here

end)

Or another way: (Takes more processing power)

while true do

--That basically updates every ten seconds. 
--Stuff in here

wait(10)
end

Hope this helped!

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