Hey,
Basically: I made an elevator for my game, but there are no errors and it doesn’t move. I’m just really getting annoyed by it and thought the devs on devforum could help.
Error: (well, not really an error. But it’s not tweening.)
--CALL ELEVATOR (FIRST BUTTON IN THE VIDEO)
local ts = game:GetService("TweenService")
local d = true
script.Parent.ProximityPrompt.Triggered:Connect(function()
if d == true then
d = false
ts:Create(script.Parent.Parent.Elevator.Door, TweenInfo.new(3, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {Position = script.Parent.Parent.Elevator.NormalPos.Position}):Play()
script.Parent.ProximityPrompt.Enabled = false
script.Parent.Parent.Elevator.SignalEleButton.ProximityPrompt.Enabled = false
wait(3)
script.Parent.Parent.Elevator.SignalEleButton.ProximityPrompt.Enabled = true
d = true
end
end)
--SIGNALELEBUTTON (2ND BUTTON YOU SAW IN THE VIDEO)
local ts = game:GetService("TweenService")
local d = true
local Points = script.Parent.Parent.Parent.Points
local NewPoint = 1
local Speed = 10
function GetTime(Distance, Speed)
local Time = Distance / Speed
return Time
end
local Train = script.Parent.Parent
Train.PrimaryPart = Train.Center
Train:SetPrimaryPartCFrame(Train.Center.CFrame)
function WeldElevator()
for i = 1, #Train:GetChildren() do
if Train:GetChildren()[i] ~= Train.PrimaryPart then
local Weld = Instance.new("WeldConstraint")
Weld.Part0 = Train:GetChildren()[i]
Weld.Part1 = Train.PrimaryPart
Weld.Parent = Train.PrimaryPart
Train:GetChildren()[i].Anchored = false
end
end
end
script.Parent.ProximityPrompt.Triggered:Connect(function()
if d == true then
d = false
ts:Create(script.Parent.Parent.Door, TweenInfo.new(3, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {Position = script.Parent.Parent.Reference.Position}):Play()
WeldElevator()
script.Parent.ProximityPrompt.Enabled = false
wait(3)
script.Event:Fire()
print("ytes")
wait(10)
d = true
end
end)
--SERVERSCRIPTSERVICE SCRIPT TO INITILAIZE TWEEN
local NewPoint = 1
local Points = game:GetService("Workspace").Points
local ts = game:GetService("TweenService")
local Train = game:GetService("Workspace").Elevator
local Speed = 10
function GetTime(Distance, Speed)
local Time = Distance / Speed
return Time
end
function MoveTrain()
NewPoint += 1
local NextPoint = Points["" .. NewPoint]
local Distance = (Train.PrimaryPart.Position - NextPoint.Position).Magnitude
local Time = GetTime(Distance, Speed)
local TweenInformation = TweenInfo.new(
Time,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)
local Tween = ts:Create(Train.PrimaryPart, TweenInformation, {CFrame = NextPoint.CFrame})
Tween:Play()
Tween.Completed:Wait() --waits until the tween finished
end
game:GetService("Workspace").Elevator.SignalEleButton.Script.Event.Event:Connect(function()
MoveTrain()
end)
Uh yeah thanks. I really don’t get it why it’s not moving, it may be a WeldConstraint problem.
Thanks