I want this to be fixed but I can't seem to figure it out. I tried getting rid of debounce but then my script runs forever and I don't need that..
wait(3) debounce = false Water = game.Workspace.Ocean2 Char = script.Parent.Parent function onTouch() if debounce == false then Foam = Instance.new("Part") Foam.Parent = Char.Character.Torso Foam.BrickColor = BrickColor.new("Mid gray") Foam.CFrame = CFrame.new(Char.Character.Torso.Position) Foam.Anchored = true Foam.CanCollide = false Foam.BottomSurface = "Smooth" Foam.TopSurface = "Smooth" Foam.Transparency = 0.35 Foam.Size = Vector3.new(6,1,6) script.Parent.Script.Sound:Play() wait(1.3) debounce = true end end Water.Touched:connect(onTouch) --// Please put your code within code blocks yourself in the future; in the question editor all you have to do is click the blue button and put your code between the lines.
All of that only happens once
You were almost there, but you need to keep in mind that the debounce needs to find a way back to being false
if you want it to run again
Your script:
wait(3) debounce = false Water = game.Workspace.Ocean2 Char = script.Parent.Parent function onTouch() if debounce == false then debounce = true --Set it true here so that it will not run again Foam = Instance.new("Part") Foam.Parent = Char.Character.Torso Foam.BrickColor = BrickColor.new("Mid gray") Foam.CFrame = CFrame.new(Char.Character.Torso.Position) Foam.Anchored = true Foam.CanCollide = false Foam.BottomSurface = "Smooth" Foam.TopSurface = "Smooth" Foam.Transparency = 0.35 Foam.Size = Vector3.new(6,1,6) script.Parent.Script.Sound:Play() wait(1.3) end --Once it's done running, the function will set debounce to 'false' again to allow it to run once more. debounce = false end Water.Touched:connect(onTouch)
Let me know if that fixes your issues or if you have any other questions.