if not Touched then line not breaking the while loop

local debounce = false

game.Players.PlayerAdded:Connect(function(player)
	local stats = Instance.new("IntValue", player)
	stats.Name = "leaderstats"
	local Time = Instance.new("IntValue", stats)
	Time.Name = "Time"
	Time.Value = 0

	local function AddTime(Touched)
		while Touched do
			wait(1)
			if debounce == false then
				Time.Value = Time.Value + 1
				debounce = true
				wait(1)
				debounce = false
			end
			if not Touched then
				break
			end
		end
	end

	workspace.Models.BASEPLATE.Touched:Connect(AddTime)
end)

2 comments

0

I think you need to use workspace.Models.BASEPLATE.TouchEnded for that.

0

It would do the same thing... Im just saying that when i touch it, it doesn't wait every second