im making a water script (please dont ask why) and its supposed to use a bodyposition to make it float. It does work but for some reason it only works for 3 times, and sometimes it doesnt even work.. why?
local debounce = false script.Parent.Touched:Connect(function(hit) if not debounce then if hit.Parent.Torso then -- i did this because sometimes a accesory will get hit debounce = true local yes = game.Players:GetPlayerFromCharacter(hit.Parent) game.Workspace.deletethingy:FireClient(yes) wait(0.00001) local e = Instance.new("BodyPosition") e.Name = "Water" e.Parent = hit.Parent.Torso e.MaxForce = Vector3.new(4000,4000*e.Parent.Parent.UpDownMultiplier.Value*10,4000) local m = game.Lighting.waterscript:Clone() m.Parent = e wait(0.3) debounce = false end end end) script.Parent.TouchEnded:Connect(function(hit) if not debounce then if hit.Parent.Torso then debounce = true local e = hit.Parent.Torso:WaitForChild("Water") e:Destroy() wait(0.3) debounce = false end end end)
Remove All Debounces