I'm trying to put a debounce and a part:remove() but it just wont' work because of my looping script. how can i make it so I can put a debounce and a part:remove() without interfering with the looping script?
local tool = script.Parent local debounce = false a = 0 b = 0 c = 0 local character = game:GetService('Players').LocalPlayer local player = character.Character or character.CharacterAdded:wait() tool.Equipped:connect(function(mouse) mouse.KeyDown:connect(function(key) if key == "e" then a = 0 b = 0 c = 0 print ("INvisibruuuuuuuu") debounce = true local part = Instance.new("Part") part.Shape = Enum.PartType.Ball part.Transparency = 0.6 part.BrickColor = BrickColor.new("Royal purple") part.CanCollide = false part.Anchored = true part.CFrame = CFrame.new(player.Torso.Position) part.Parent = game.Workspace wait(2) part:remove() repeat part.Size = Vector3.new(a,b,c) a = a +.5 b = b +.5 c = c +.5 wait(.1) until part.Size == Vector3.new(10,10,10) end end) end)
the looping script is making the sphere bigger, but if i put a debounce after the:
until part.Size == Vector3.new(10,10,10)
then it won't stop making the sphere bigger until the deboucne is == false and the part is removed. Please help, this is my ideal code:
local tool = script.Parent local debounce = false a = 0 b = 0 c = 0 local character = game:GetService('Players').LocalPlayer local player = character.Character or character.CharacterAdded:wait() tool.Equipped:connect(function(mouse) mouse.KeyDown:connect(function(key) if key == "e" then a = 0 b = 0 c = 0 print ("INvisibruuuuuuuu") debounce = true local part = Instance.new("Part") part.Shape = Enum.PartType.Ball part.Transparency = 0.6 part.BrickColor = BrickColor.new("Royal purple") part.CanCollide = false part.Anchored = true part.CFrame = CFrame.new(player.Torso.Position) part.Parent = game.Workspace wait(2) part:remove() repeat part.Size = Vector3.new(a,b,c) a = a +.5 b = b +.5 c = c +.5 wait(.1) until part.Size == Vector3.new(10,10,10) end wait(2) debounce = false part:remove() end) end)