I want to make a railroad crossing that uses Tween service to tween the gate up and down and so I can use it around my map.
It works byTweening a part were the gate would pivot.
It works good In the direction it was made in but it starts to break when you put it in a different orientation.
It looks like the gate tweens back to the orignal position it was built in.
Rotated 90 Degrees
I have tried to update the CFrame before the gate even does anything but for me it didn’t work.
I don’t really know what to do next.
Script:
local tween = game:GetService("TweenService")
local center = script.Parent.Gate.Center-- the part that we are tweening
local activated = script.Parent.IsOn -- A bool value that controls the crossing gate
local tweeningInformation = TweenInfo.new(
8,
Enum.EasingStyle.Quad
)
local PropertiesChange1 = {
Orientation = Vector3.new(0,0,0)
}
local PropertiesChange2 = {
Orientation = Vector3.new(0,0,-90)
}
script.Parent.IsOn.Changed:Connect(function()
if activated.Value == true then
wait(2)
tween:Create(center,tweeningInformation,PropertiesChange2):play()
else
tween:Create(center,tweeningInformation,PropertiesChange1):play()
end
end)