Title might not make sense, but what I want to know is how do you make a sliding part that will go back to it's original position after a few seconds of being activated. What I am trying to make is a door that will slide open when touched and then slide back closed after 2.5 seconds. Thanks!
local sp=script.Parent function onTouched(hit) if hit.Parent:FindFirstChild("Humanoid") then for i=1,10 do wait(.1) sp.CFrame=CFrame.new(-60.6-i, 0.6, 124) end wait(2.5) for i=1,10 do wait(.1) sp.CFrame=CFrame.new(-70.6+i, 0.6, 124) end end end sp.Touched:connect(onTouched)
Now for an explanation.
if hit.Parent:FindFirstChild("Humanoid") then
We make sure it was a player that touched it.
for i=1,10 do
This for loop repeats itself ten times before moving on.
wait(.1)
We wait .1 seconds before running the rest of the loop.
sp.CFrame=CFrame.new(-60.6-i, 0.6, 124)
Now, since i=1 we can use i to move the block -10 studs over. You need to change the Position though since my brick is not in the same position as your brick.
wait(2.5)
Now we wait 2.5 seconds to run the next for loop.
sp.CFrame=CFrame.new(-70.6+i, 0.6, 124)
Now make sure you corrected the blocks position since it moved, and this time we add 1 ten times. Moving the brick a +10 studs over, bringing it back to it's original position.