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

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

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

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

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