I’m trying to make an elevator door which opens up with a tween after a short intermission, however I get the error Unable to cast to dictionary
at line 28 when trying to setup the tween. Why is that?
Here’s the script (excludes content not related to the tween):
local DoorParts = game:GetService("Workspace").Doors
local LD = DoorParts.LeftDoor
local LO = DoorParts.LO.CFrame -- Left door closed goal
local LC = DoorParts.LC.CFrame -- Left door closed goal
local RD = DoorParts.RightDoor
local RO = DoorParts.RO.CFrame -- Right door open goal
local RC = DoorParts.RC.CFrame -- Right door closed goal
local TweenService = game:GetService("TweenService")
local TweenStyle = TweenInfo.new(.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
local OpenTweenL = TweenService:Create(LD, TweenStyle, LO) -- WHERE I GET ERROR MESSAGE (line 28)
local OpenTweenR = TweenService:Create(RD, TweenStyle, RO)
local ClosedTweenL = TweenService:Create(LD, TweenStyle, LC)
local ClosedTweenR = TweenService:Create(RD, TweenStyle, RC)
-- pick world
local function pickworld()
local topick = math.random(1, #Worlds:GetChildren())
local copy = Worlds[topick]:Clone()
copy.Parent = ActiveWorld
end
-- open doors
local function opendoors()
OpenTweenL:Play()
OpenTweenR:Play()
end
Here's the script in whole as well in case that helps
local ActiveWorld = game:GetService("Workspace").ActiveWorld
local Worlds = game:GetService("ServerStorage").Worlds
local WorldTimer = game:GetService("ReplicatedStorage").Timer.WorldTimer
local players = game:GetService("Players")
local TimeperWorld = 0.1 -- (minutes)
local ElevatorTime = 15 -- (seconds)
local intermission = false
-- Door parts
local DoorParts = game:GetService("Workspace").Doors
local LD = DoorParts.LeftDoor
local LO = DoorParts.LO.CFrame -- Left door closed goal
local LC = DoorParts.LC.CFrame -- Left door closed goal
local RD = DoorParts.RightDoor
local RO = DoorParts.RO.CFrame -- Right door open goal
local RC = DoorParts.RC.CFrame -- Right door closed goal
local TweenService = game:GetService("TweenService")
local TweenStyle = TweenInfo.new(.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
local OpenTweenL = TweenService:Create(LD, TweenStyle, LO) -- WHERE I GET ERROR MESSAGE (line 28)
local OpenTweenR = TweenService:Create(RD, TweenStyle, RO)
local ClosedTweenL = TweenService:Create(LD, TweenStyle, LC)
local ClosedTweenR = TweenService:Create(RD, TweenStyle, RC)
-- pick world
local function pickworld()
local topick = math.random(1, #Worlds:GetChildren())
local copy = Worlds[topick]:Clone()
copy.Parent = ActiveWorld
end
-- open doors
local function opendoors()
OpenTweenL:Play()
OpenTweenR:Play()
end
-- close doors
local function closedoors()
-- ClosedTweenL:Play()
-- ClosedTweenR:Play()
end
-- waiting between levels
local function intermission()
local timeleft = ElevatorTime
while timeleft > 0 do
timeleft = timeleft - 1
wait(1)
WorldTimer:FireAllClients(timeleft)
if timeleft== 0 then
pickworld()
opendoors()
end
end
end
-- level
while true do
intermission()
wait (ElevatorTime)
local timeleft = TimeperWorld * 60
while timeleft > 0 do
timeleft = timeleft - 1
wait(1)
WorldTimer:FireAllClients(timeleft)
end
end