local mopBrush = script.Parent
local debounce = false
local currentSpills = 5
wait(5)
game.Players.PlayerAdded:Connect(function(player)
mopBrush.Touched:Connect(function(hit)
if hit.Name == "Spill" then
if debounce == false then
if currentSpills > 0 then
if hit.Size == Vector3.new(0.076,0.36,0.36) then
debounce = true
hit.Size = hit.Size - Vector3.new(0,0.36,0.36)
currentSpills = currentSpills - 1
script.Parent.Parent.Parent.ToolTip = "Mop: "..currentSpills.."/5"
player:WaitForChild("leaderstats"):WaitForChild("Points").Value = player:WaitForChild("leaderstats"):WaitForChild("Points").Value + 2
wait(0.5)
debounce = false
else
debounce = true
hit.Size = hit.Size - Vector3.new(0,0.36,0.36)
wait(0.5)
debounce = false
end
end
end
end
end)
end)
This is supposed to make it so that when the brush touches the spill. the spill shrinks, but nothing happens when it touches it.
blokav
(blokav)
#2
You don’t need PlayerAdded for this.
I don’t know the rest of your script’s context (where it’s located, etc.) so this may or may not work:
local mopBrush = script.Parent
local debounce = false
local currentSpills = 5
mopBrush.Touched:Connect(function(hit)
if hit.Name == "Spill" and debounce == false and currentSpills > 0 then
debounce = true
hit.Size = hit.Size - Vector3.new(0,0.36,0.36)
currentSpills = currentSpills - 1
script.Parent.Parent.Parent.ToolTip = "Mop: "..currentSpills.."/5"
local player = game.Players:GetPlayerFromCharacter(script.Parent.Parent.Parent.Parent)
player:WaitForChild("leaderstats"):WaitForChild("Points").Value = player:WaitForChild("leaderstats"):WaitForChild("Points").Value + 2
wait(0.5)
debounce = false
end
end)
It still doesnt do anything when it touches the spill.
14:01:02.462 - Infinite yield possible on ‘Players.U_npluggedDev:WaitForChild(“leaderstats”)’
dmksa123
(dmk)
#7
That means that leaderstats is not a thing.
Touched events are often unreliable. I recommend you do raycasting for this.