Hello all,
I need help with animating gates for subway station with ticket to scan it.
Hello all,
I need help with animating gates for subway station with ticket to scan it.
if its a swinging door you want, this script might be a good starting point - I'm using it at the moment so there are probably some bits that you'll need to change (like getting rid of the gui parts) but you can adapt it as you see fit!
Hope it helps
local door = script.Parent.Parent.Parent.top.bars
local door1 = script.Parent.Parent.Parent.top.wood
local clicked = script.Parent.ClickDetector
local canClick = true
local swing = 0.5 --- the angle to open the door by
-- locate the hinge on the door
local hingeBefore = door.CFrame * CFrame.new(0, (-1.625/2), (4.476/2))
-- relative to the hinge, where is the door?
local relative = hingeBefore:toObjectSpace(door.CFrame)
-- twist the hinge
local hingeAfter = hingeBefore * CFrame.Angles(0, 0, 0)
-- re-attach the door to the new "hinge"
door.CFrame = hingeAfter:toWorldSpace(relative)
-- swing the door by `angle` degrees
function swingDoor(angle)
-- locate the hinge on the door
local hingeBefore = door.CFrame * CFrame.new(0, (-1.275/2), (3.725/2))
-- relative to the hinge, where is the door?
local relative = hingeBefore:toObjectSpace(door.CFrame)
-- twist the hinge
-- CONVERT angle *from* degrees *to* radians here
local hingeAfter = hingeBefore * CFrame.Angles(math.rad(angle), 0, 0)
-- re-attach the door to the new "hinge"
door.CFrame = hingeAfter:toWorldSpace(relative)
door1.CFrame = hingeAfter:toWorldSpace(relative)
end
clicked.MouseClick:connect(function(playerClicked)
local gui = playerClicked.PlayerGui:WaitForChild("home_bank")
if canClick == true
then canClick = false
gui.Enabled = true
for i = 1, 100 do
swingDoor(swing)
wait()
end
for i = 1, 100 do
swingDoor(-swing)
wait()
end
canClick = true
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
Ok so first, go to animation editor then make an animation
...animation editor is for animating humanoids and not blocks...