Log in to vote
0

# My Elevator Script does not work :/ can anybody see whats the problem?

Asked by 3 years ago
Edited 3 years ago

This script does not work , can anyone see if there is a problem?

local part = script.Parent

local tweenservice = game:GetService("TweenService")

local tweenInfo = TweenInfo.new(2,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0)

local Up = {CFrame = part.CFrame + part.CFrame.Position  (0,1.296,0) }

local Down = {CFrame = part.CFrame + part.CFrame.Position  (0,-1.296,0) }

GoDown = tweenservice:Create(part,tweenInfo,Up)
GoUp = tweenservice:Create(part,tweenInfo,Down)

while true do

wait(3)
GoDown:Play()
wait(3)
GoUp:Play()
wait()
end

0
Any errors or anything? Is the elevator not moving at all or moving to a wrong direction? starmaq 1290 — 3y
0
In line 12 and 15 you also have something weird going on which is this part.CFrame + part.CFrame.Position (0,1.296,0), the (0,1.296,0) is not in the right place, it would create a syntax error starmaq 1290 — 3y
0
oh DesiredToResign 10 — 3y

### 1 answer

Log in to vote
0
Answered by
sleazel 1282
3 years ago

To move parts correctly using CFrames, please use Vector3.new.

local part = script.Parent

local tweenservice = game:GetService("TweenService")

local tweenInfo = TweenInfo.new(2,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0)

local Up = {CFrame = part.CFrame + Vector3.new(0,1.296,0) }

local Down = {CFrame = part.CFrame + Vector3.new(0,-1.296,0) }

GoDown = tweenservice:Create(part,tweenInfo,Up)
GoUp = tweenservice:Create(part,tweenInfo,Down)

while true do

wait(3)
GoDown:Play()
wait(3)
GoUp:Play()
wait()
end


Down tween will actually move elevator below initial position. If you just want to go back to the starting position use:

local Down = {CFrame = part.CFrame }



Have a nice scripting session!

0
thank you so much! DesiredToResign 10 — 3y