Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

A failed brick moving script! Someone help me?

Asked by 9 years ago

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

Log in to vote
0
Answered by 9 years ago

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

0
No! Lock3 and Lock4 aren't members of parts. StickMasterNinja2 0 — 9y
Ad

Answer this question