I am building a drawbridge, and i watched a youtube video. I am trying to make it so the drawbridge goes down to the ground then pulls back up again. The second part is not working, and instead just resets from a 0 0 0 orientation and then repeats the going down part. Here is my script, anything helps.
local cd = script.Parent.ClickDetector
local ori = script.Parent.Lever.Orientation.X
local click = script.Parent.Sound
local down = false
local lever = script.Parent.Lever
local down = false
local Bridge = workspace.Drawbridge.SoundTwo
local door = workspace:WaitForChild("Drawbridge")
local hinge = workspace:WaitForChild("DrawbridgeHinge")
local hinget = workspace:WaitForChild("DrawbridgeHinge2")
local HingePos = hinge.Position
local HingetPos = hinget.Position
local thump = workspace.Drawbridge.Thump
cd.MouseClick:Connect(function()
if down == false then
wait(0.2)
click:Play()
lever.Orientation = Vector3.new(30, 180, 180)
Bridge:Play()
for i = 1, 90 do
door.CFrame = CFrame.new(HingePos) * CFrame.Angles(math.rad(i),0,0) * CFrame.new(0,19.87,0)
wait()
end
Bridge:Stop()
thump:Play()
wait(2)
thump:Stop()
down = true
else
wait(0.2)
click:Play()
lever.Orientation = Vector3.new(0,180,180)
Bridge:Play()
for i = 1, 90 do
door.CFrame = CFrame.new(HingetPos) * CFrame.Angles(math.rad(-i),0,0) * CFrame.new(0,19.87,0)
wait()
end
Bridge:Stop()
thump:Play()
wait(2)
thump:Stop()
down = false
end
end)

1 comment
You could also animate the doors if you want like how you are animating the bridge.