So I made a basic script, but when i go in game, it runs the BrickColor changes, and the transparency but then repeats, it starts from the start how do i make it so at the last command just stop?
script.Parent.Touched:connect(function() script.Parent.BrickColor = BrickColor.new("Really red") wait(2) script.Parent.Transparency = 0.6 wait(3) script.Parent.BrickColor = BrickColor.new("Bright blue") end)
the last brickcolor change that makes it Bright Blue to just stop - line 6
It repeats because the Touched event fires multiple times when something collides with that part. You can add a debounce to fix this.
local debounce = true script.Parent.Touched:Connect(function() if debounce then debounce = false script.Parent.BrickColor = BrickColor.new("Bright red") wait(2) script.Parent.Transparency = 0.6 wait(3) script.Parent.BrickColor = BrickColor.new("Bright blue") debounce = true --remove this line if you only want it to hapen once end end)