Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

A failed brick moving script! Someone help me?

Satan, did you broken it?

Door1 = game.Workspace.Structure.Door.Left
Door2 = game.Workspace.Structure.Door.Right

function onTouch(hit)
	for i=1,20 do
	Door1.Lock3.CFrame = Door1.Lock3.CFrame * CFrame.new(0,1,0)
	Door2.Lock4.CFrame = Door2.Lock4.CFrame * CFrame.new(0,-1,0)
	wait(10)
	for i=1,20 do
		Door1.Lock3.CFrame = Door1.Lock3.CFrame * CFrame.new(0,-1,0)
		Door2.Lock4.CFrame = Door2.Lock4.CFrame * CFrame.new(0,1,0)
	end
	end
end

script.Parent.Touched:connect(onTouch)

1 answer

First, I think your script actually makes the left door stay in the same place (as you're multiplying a number by 1, thus making it the same), and the right door moves from a positive position to its negative equivalent (for example, if the position is 10, 5, 10; then the door will move from 5 in the Y-Axis to -5 in the same axis)

You could make something like this to make it look smooth

t = false     -- Just a debouncer

if t == false then
     t = true     -- Activates te debounce
     for i = 1, 20 do     -- Run the first loop
          Door1.Lock3.CFrame = Door1.Lock3.CFrame + CFrame.new(0, 0.1, 0)
          Door2.Lock4.CFrame = Door2.Lock4.CFrame + CFrame.new(0, -0.1, 0)
          wait()     -- A wait for the loop to work
          end     -- Stops the loop from going past this point
          wait(10)     -- Once the loop finishes, wait 10 seconds
          for i = 1, 20 do     -- Run the second loop
               Door1.Lock3.CFrame = Door1.Lock3.CFrame - CFrame.new(0, 0.1, 0)
               Door2.Lock4.CFrame = Door2.Lock4.CFrame - CFrame.new(0, -0.1, 0)
               wait()     -- Wait stops the loop from freezing the script
               end     -- Ends the second loop
          t = false     -- Deactivates the debounce
end

That should work (I'm not very sure about the syntax because I wrote this answer from my iPhone)

mranderson11

1 comment

0

No! Lock3 and Lock4 aren't members of parts.

This discussion is preserved as it was. New answers, comments, and votes are closed.