Script doesn't want to work after I converted it into a localscript

Hi there,
I have this elevator script that I’ve been using in a server script and after I saw it lagged alot I decided to change it into a local script. The problem is that I didn’t change anything in the code and it just doesn’t work in a local script. I don’t really know why it doesn’t work, I looked through the whole code to see if there were any errors but the output doesn’t say that the code has an error in it. Any ideas’ why it doesn’t work?

local ProximityPromptService = game:GetService("ProximityPromptService")
local Prx = script.Parent
Prx.Enabled = true

local state = "Up"
local Folder = script.Parent.Parent.Parent.Parent.Parent
local Elevator1 = Folder.Elevator.Main
local Doorsound1 = Folder.Elevator.RightDoor["Elevator Doors Open Close 14 (SFX)"]
local Doorsound2 = Folder.Elevator.LeftDoor["Elevator Doors Open Close 14 (SFX)"]
local Doorsound3 = Folder.Elevator.DownRightDoor["Elevator Doors Open Close 14 (SFX)"]
local Doorsound4 = Folder.Elevator.DownRightDoor["Elevator Doors Open Close 14 (SFX)"]
local CallLiftDown = Folder.Elevator.CallLiftDown
local CallLiftUp = Folder.Elevator.CallLiftUp

-- Door Stuff Start

local door1left = script.Parent.Parent.Parent.Parent.LeftDoor
local door1right = script.Parent.Parent.Parent.Parent.RightDoor
local door2left = script.Parent.Parent.Parent.Parent.Parent.ElevatorUpDoors.Door2left
local door2right = script.Parent.Parent.Parent.Parent.Parent.ElevatorUpDoors.Door2Right
local door3right = script.Parent.Parent.Parent.Parent.Parent.ElevatorDownDoors.Door2Right
local door3left = script.Parent.Parent.Parent.Parent.Parent.ElevatorDownDoors.Door2left
local DownLeftDoor = script.Parent.Parent.Parent.Parent.DownLeftDoor
local DownRightDoor = script.Parent.Parent.Parent.Parent.DownRightDoor
local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(18,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,0,false,0)
local doortweenInfo = TweenInfo.new(3)


-- Left1DoorTween

local Left1GoalOpen = {}
local Left1GoalClose = {}
Left1GoalOpen.CFrame = door1left.CFrame * CFrame.new(door1left.Size.X, 0, 0)
Left1GoalClose.CFrame = door1left.CFrame
local left1TweenOpen = TweenService:Create(door1left, doortweenInfo, Left1GoalOpen)
local left1TweenClose = TweenService:Create(door1left, doortweenInfo, Left1GoalClose)

-- Right1DoorTween

local Right1GoalOpen = {}
local Right1GoalClose = {}
Right1GoalOpen.CFrame = door1right.CFrame * CFrame.new(-door1right.Size.X, 0, 0)
Right1GoalClose.CFrame = door1right.CFrame
local Right1TweenOpen = TweenService:Create(door1right, doortweenInfo, Right1GoalOpen)
local Right1TweenClose = TweenService:Create(door1right, doortweenInfo, Right1GoalClose)

-- Left2DoorTween

local Left2GoalOpen = {}
local Left2GoalClose = {}
Left2GoalOpen.CFrame = door2left.CFrame * CFrame.new(door2left.Size.X, 0, 0)
Left2GoalClose.CFrame = door2left.CFrame
local left2TweenOpen = TweenService:Create(door2left, doortweenInfo, Left2GoalOpen)
local left2TweenClose = TweenService:Create(door2left, doortweenInfo, Left2GoalClose)

-- Right2DoorTween

local Right2GoalOpen = {}
local Right2GoalClose = {}
Right2GoalOpen.CFrame = door2right.CFrame * CFrame.new(-door2right.Size.X, 0, 0)
Right2GoalClose.CFrame = door2right.CFrame
local Right2TweenOpen = TweenService:Create(door2right, doortweenInfo, Right2GoalOpen)
local Right2TweenClose = TweenService:Create(door2right, doortweenInfo, Right2GoalClose)

-- Left3DoorTween

local Left3GoalOpen = {}
local Left3GoalClose = {}
Left3GoalOpen.CFrame = door3left.CFrame * CFrame.new(door3left.Size.X, 0, 0)
Left3GoalClose.CFrame = door3left.CFrame
local left3TweenOpen = TweenService:Create(door3left, doortweenInfo, Left3GoalOpen)
local left3TweenClose = TweenService:Create(door3left, doortweenInfo, Left3GoalClose)

-- Right3DoorTween

local Right3GoalOpen = {}
local Right3GoalClose = {}
Right3GoalOpen.CFrame = door3right.CFrame * CFrame.new(-door3right.Size.X, 0, 0)
Right3GoalClose.CFrame = door3right.CFrame
local Right3TweenOpen = TweenService:Create(door3right, doortweenInfo, Right3GoalOpen)
local Right3TweenClose = TweenService:Create(door3right, doortweenInfo, Right3GoalClose)

-- Down Left Door

local DownLeftGoalOpen = {}
local DownLeftGoalClose = {}
DownLeftGoalOpen.CFrame = DownLeftDoor.CFrame * CFrame.new(DownLeftDoor.Size.X, 0, 0)
DownLeftGoalClose.CFrame = DownLeftDoor.CFrame
local LeftDownTweenOpen = TweenService:Create(DownLeftDoor, doortweenInfo, DownLeftGoalOpen)
local LeftDownTweenClose = TweenService:Create(DownLeftDoor, doortweenInfo, DownLeftGoalClose)

-- DownRightDoor

local DownRightGoalOpen = {}
local DownRightGoalClose = {}
DownRightGoalOpen.CFrame = DownRightDoor.CFrame * CFrame.new(-DownRightDoor.Size.X, 0, 0)
DownRightGoalClose.CFrame = DownRightDoor.CFrame
local DownRightTweenOpen = TweenService:Create(DownRightDoor, doortweenInfo, DownRightGoalOpen)
local DownRightTweenClose = TweenService:Create(DownRightDoor, doortweenInfo, DownRightGoalClose)

-- Door STuff End and Script Start

Right2TweenOpen:Play()
left2TweenOpen:Play()
task.wait(0.3)
Right1TweenOpen:Play()
left1TweenOpen:Play()

-- Elevator Script start

local Studs = 54.509
local LeftDoorUp1 = {CFrame = door1left.CFrame}
local LeftDoorDown1 = {CFrame = door1left.CFrame + door1left.CFrame.UpVector * -Studs}
local RightDoorUp1 = {CFrame = door1right.CFrame}
local RightDoorDown1 = {CFrame = door1right.CFrame + door1right.CFrame.UpVector * -Studs}
local Up = {CFrame = Elevator1.CFrame}
local Down = {CFrame = Elevator1.CFrame + Elevator1.CFrame.UpVector * -Studs}

local CarDown = TweenService:Create(Elevator1,tweenInfo,Down)
local CarUp = TweenService:Create(Elevator1,tweenInfo,Up)

local LeftDoorUp = TweenService:Create(door1left,tweenInfo,LeftDoorUp1)
local LeftDoorDown = TweenService:Create(door1left,tweenInfo,LeftDoorDown1)

local RightDoorUp = TweenService:Create(door1right,tweenInfo,RightDoorUp1)
local RightDoorDown = TweenService:Create(door1right,tweenInfo,RightDoorDown1)

local d = false

script.Parent.Triggered:Connect(function()

	if state == "Up" and d == false then

		d = true
		Folder.Elevator.Main.Elevatorclose.ProximityPrompt.Enabled = false
		Doorsound1:Play()
		Doorsound2:Play()
		Right2TweenClose:Play()
		left2TweenClose:Play()
		task.wait(0.3)
		Right1TweenClose:Play()
		left1TweenClose:Play()
		Folder.Elevator.Main.Elevatorclose["Beep Sound affect"]:Play()
		Folder.Elevator.Main.Elevatorclose.DownSound:Play()
		task.wait(2.5)
		Folder.Elevator.Main.Elevatorclose.LongBeep:Play()
		task.wait(1)
		Folder.Elevator.Main["elevator move"]:Play()
		LeftDoorDown:Play()
		RightDoorDown:Play()
		CarDown:Play()
		task.wait(20)
		Folder.Elevator.Main["elevator move"]:Stop()
		Folder.Elevator.Main.Elevatorclose.LongBeep:Play()
		task.wait(0.5)
		door1left.Transparency = 1
		door1right.Transparency = 1
		door1left.CanCollide = false
		door1right.CanCollide = false
		Doorsound3:Play()
		Doorsound4:Play()
		DownRightTweenOpen:Play()
		LeftDownTweenOpen:Play()
		wait(0.3)
		Right3TweenOpen:Play()
		left3TweenOpen:Play()
		state = "Down"
		d = false
		Folder.Elevator.Main.Elevatorclose.ProximityPrompt.Enabled = true

	elseif state == "Down" and d == false then

		d = true
		Folder.Elevator.Main.Elevatorclose.ProximityPrompt.Enabled = false
		Doorsound3:Play()
		Doorsound4:Play()
		Right3TweenClose:Play()
		left3TweenClose:Play()
		task.wait(0.3)
		DownRightTweenClose:Play()
		LeftDownTweenClose:Play()
		Folder.Elevator.Main.Elevatorclose["Beep Sound affect"]:Play()
		Folder.Elevator.Main.Elevatorclose.UpSound:Play()
		task.wait(2.5)
		Folder.Elevator.Main.Elevatorclose.LongBeep:Play()
		task.wait(1)
		Folder.Elevator.Main["elevator move"]:Play()
		door1left.Transparency = 0
		door1right.Transparency = 0
		door1left.CanCollide = true
		door1right.CanCollide = true
		CarUp:Play()
		LeftDoorUp:Play()
		RightDoorUp:Play()
		wait(20)
		Folder.Elevator.Main["elevator move"]:Stop()
		Folder.Elevator.Main.Elevatorclose.LongBeep:Play()
		task.wait(0.5)
		Doorsound1:Play()
		Doorsound2:Play()
		left1TweenOpen:Play()
		Right1TweenOpen:Play()
		wait(0.3)
		Right2TweenOpen:Play()
		left2TweenOpen:Play()
		state = "Up"
		d = false
		Folder.Elevator.Main.Elevatorclose.ProximityPrompt.Enabled = true

	end
end)


-- {Position = Vector3.new(4.298, 5.101, -202.560),}
-- {Position = Vector3.new(8.615, 9.138, -201.535),}
-- {Position = Vector3.new(8.615, 9.138, -203.802),}	

Sorry for the long script.

Where is the local script?

1 Like

It’s inside a proximity prompt. I have placed local scripts in proximity prompts many times and it worked without any problems.

try using print() for debugging. You have to know which part is working properly or not (or maybe whole script).

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.