Tried to make a script that would give you one point, for every second you stood in a region. Like KOTH. I used some scripts from some tutorials on youtube. But I don't know where to place the debounce? Pls help.

local function ifplayerjoined(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
 
	local gold = Instance.new("IntValue")
	gold.Name = "Points"
	gold.Value = 0
	gold.Parent = leaderstats
	local region = Region3.new(Vector3.new(0,0,0), Vector3.new(15,15,15))

local part = Instance.new("Part")
part.Anchored = true
part.Size = region.Size
part.Parent = game.Workspace
part.CanCollide = false
local touchedregion = false
while true do
	wait(1)
	local partsinregion = workspace:FindPartsInRegion3(region, part, 1000)
		for i, part in pairs(partsinregion) do
--where debounce comes
			if not touchedregion then
				touchedregion = true
			if part.Parent:FindFirstChild("Humanoid") then
				
					
					player.leaderstats.Points.Value = player.leaderstats.Points.Value + 1
					touchedregion = false
				end
			
		end
	end
end
end

game.Players.PlayerAdded:Connect(ifplayerjoined)


1 comment

0

touchedregion seems to already be your denounce and seems to be in the right spot