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

How do I kick a player once they have 0 points?

Asked by 1 year ago

I am making a 'limited words' based game, and trying to kick a player when they have 0 points. For some reason, it wont work. Can anyone help? Here is the script;

game.Players.PlayerAdded:Connect(function(player)
    if player.leaderstats.Points.Value <= 0 then
        player:Kick("You ran out of points!")
    end
end)

1 answer

Log in to vote
0
Answered by 1 year ago

Your current code only checks if the player’s point is 0 once when they just joined. Instead try checking every time their point changes.

local Players = game:GetService('Players')

Players.PlayerAdded:Connect(function(player)
    local pointsValue = player.leaderstats.Points

    pointsValue.Changed:Connect(function()
        if pointsValue.Value <= 0 then
            player:Kick('You ran out of points!')
        end
    end)
end)
0
Thanks salaarkhan1 28 — 1y
Ad

Answer this question