I have a script that when a character runs over the top of a part, the part will go sideways a tiny bit, but when it is touched, instead of moving sideways, it will go upwards infinitely. Script:
local Part = workspace.ManholeCover.Union -- this is the Part we will move
local newPos = Part.Position + Vector3.new(-27.313,285.446,-9.8) -- the position the Part will go to
local Time = 0.5 -- the time that the script will take to move the part
local Increment = 0.5 -- the Part will move 0.5 studs each time it moves
local Debounce = false
local Diff = newPos - Part.Position -- the difference between the two positions
local Mag = Diff.magnitude -- the distance between the two parts
local Direction = CFrame.new(Part.Position, newPos).lookVector
function MovePart() -- function to move the Part
if Debounce then return end -- end the function if debounce is true
Debounce = true -- make Debounce true so the function can't run
for n = 0, Mag, Increment do
Part.CFrame = Part.CFrame + (Direction * Increment)
wait( (Time/Mag) * Increment )
end
Debounce = false -- set Debounce to false so the function can run again
end
workspace.ManholeCover.Union.Cell.Touched:connect(MovePart)

1 comment
The debounce sets to true, then sets it to false causing it to run infinitely. Try putting a 'if Part.CFrame == CFrame.new(1, 1, 1) then ... debounce = false'