I am trying to make an elevator and for that I made a function which would tween the elevator primarypartCFrame to another position (move between different floors)
The tween works fine except for the fact that it doesn’t animate but moves instantly? The position the tween moves to works but the animation just doesn’t play.
If have tried playing the tween outside the modulescript but it didn’t change anything.
Modulescript:
local TweenService = game:GetService("TweenService")
local floors = game.Workspace.ElevatorPositions
local elevator = script.Parent
local currentFloor = 8
local elevatorM = {}
elevatorM.MoveElevator = function(floor)
local floorsToMove = currentFloor - floor
local floorPosition = floors["Floor"..floor].Position
print(floorPosition)
local elevatorTweenInfo = TweenInfo.new(floorsToMove*2,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,0,false,0)
local elevatorGoal = {
elevator:SetPrimaryPartCFrame(CFrame.new(floorPosition.X,floorPosition.Y,floorPosition.Z))
}
local elevatorTween = TweenService:Create(elevator,elevatorTweenInfo,elevatorGoal)
elevatorM.elevatorTweenV = elevatorTween
elevatorTween:Play()
end
return elevatorM
Explorer screenshot (Elevator script calls the MoveElevator function with prefered floor number)