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

Need help stopping an intvalue from going up when a player touches a part?

Asked by 3 years ago

Im trying to make it so that when a player touches a zone, they stop getting points. I have a while loop in a serverscript that gives each player a point every second. How would I stop an intvalue from going up when a player touches the zone?

1 answer

Log in to vote
0
Answered by 3 years ago

Hiya,

You can use

BasePart:GetTouchingParts() 
--> Returns list of touching parts

to get a table of all touching parts, using this you can check if the part is an object of a character, then getting the player using

game:GetService("Players"):GetPlayerFromCharacter(BasePart.Parent)
--> Returns player object

and adding that to an exception list in your server script. like;

local exception = {}

while wait(5) do
    for index, player in pairs(game:GetService("Players"):GetPlayers()) do
        if table.find(exception, player) == nil then
            -- Add points
        end
    end
end
Ad

Answer this question