Spill giving insane amounts of points instead of giving 1

So, I made my own spill system and when I clean the spill, the spill gives insane amounts of points instead of giving 1 and I still havent figured out how to solve this issue, I have been trying for like the past hour.

Here’s the code:

local Spill = script.Parent
local TweenService = game:GetService("TweenService")
local tween = TweenService:Create(Spill, TweenInfo.new(5, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), {Size = Vector3.new(0,0,0)})
local Debounce = false

game.Players.PlayerAdded:Connect(function(Player)
   Spill.Touched:Connect(function(Touch)
   	if Touch.Parent.Name == "Mop" then
   		if Debounce == false then
   			Debounce = true
   			if Spill.Transparency == 0 then
   				tween:Play()
   				repeat wait() until Spill.Size == Vector3.new(0.001, 0.001, 0.001)
   				Spill.Transparency = 1
   				Spill.Size = Vector3.new(0.05, 5.375, 5.375)
   				Player.leaderstats.Points.Value += 1
   			end
   			Debounce = false
   		end
   	end
   end)

   Spill.TouchEnded:Connect(function()
   	tween:Pause()
   	Debounce = false
   end)
end)

You are not waiting before setting the debounce back.

Fixed:

  • Added a wait(2)
game.Players.PlayerAdded:Connect(function(Player)
   Spill.Touched:Connect(function(Touch)
   	if Touch.Parent.Name == "Mop" then
   		if Debounce == false then
   			Debounce = true
   			if Spill.Transparency == 0 then
   				tween:Play()
   				repeat wait() until Spill.Size == Vector3.new(0.001, 0.001, 0.001)
   				Spill.Transparency = 1
   				Spill.Size = Vector3.new(0.05, 5.375, 5.375)
   				Player.leaderstats.Points.Value += 1
   			end
                        wait(2)
   			Debounce = false
   		end
   	end
   end)
1 Like

they also mess with the debounce using TouchEnded, this is another reason why it doesn’t work

EDIT: also use task.wait()
wait is deprecated pretty much

I just don’t want to tween to continue when the player is not touching, it just doesn’t make sense.
Edit: The wait(2) seemed to work, thanks!

no I said the debounce not the tween

a Touched event will run and then the TouchEnded will run after, since Touched runs many times it will make debounce false easily