Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

3 comments

0

Any errors or anything? Is the elevator not moving at all or moving to a wrong direction?

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

0

oh

1 answer

✓ Accepted answer

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!

1 comment

0

thank you so much!

This discussion is preserved as it was. New answers, comments, and votes are closed.