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

Unable to cast dictionary when making a door. Any fixes?

Not sure why I am getting this error. Code:

local Cart = script.Parent.Elevator
local tweenService = game:GetService("TweenService")
local F0 = script.Parent.F0ElevatorDoor
local F1 = script.Parent.F1ElevatorDoor
local F2 = script.Parent.F2ElevatorDoor
local CurrentFloor = 0
local info = TweenInfo.new(3, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
local function tweenModel(model, cframe, time)
	local cframeValue = Instance.new("CFrameValue")
	cframeValue.Value = model:GetPrimaryPartCFrame()

	cframeValue:GetPropertyChangedSignal("Value"):connect(function()
		model:SetPrimaryPartCFrame(cframeValue.Value)
	end)

	local info = TweenInfo.new(time, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
	local tween = tweenService:Create(cframeValue, info, {Value = cframe})
	tween:Play()

	tween.Completed:connect(function()
		cframeValue:Destroy()
	end)
end
local CFrames = {
	F0D1OP1 = script.Parent.F0ElevatorDoor.D1O.First.CFrame, -- F0D1OP1 - Floor, Door, State, Part
	F0D1OP2 = script.Parent.F0ElevatorDoor.D1O.Second.CFrame,
	F0D1OP3 = script.Parent.F0ElevatorDoor.D1O.Third.CFrame,
	F0D2OP1 = script.Parent.F0ElevatorDoor.D2O.First.CFrame,
	F0D2OP2 = F0.D2O.Second.CFrame,
	F0D2OP3 = F0.D2O.Third.CFrame,
	F0D1CP1 = F0.D1C.First.CFrame,
	F0D1CP2 = F0.D1C.Second.CFrame,
	F0D1CP3 = F0.D1C.Third.CFrame
	-- end of floor 0
	
}
local F0OpenP1 = tweenService:Create(F0.Door1.First, info, CFrames.F0D1OP1)
local F0OpenP2 = tweenService:Create(F0.Door1.Second, info, CFrames.F0D1OP2)
local F0OpenP3 = tweenService:Create(F0.Door1.Third, info, CFrames.F0D1OP3)
F0OpenP1:Play()
F0OpenP2:Play()
F0OpenP3:Play()

1 answer

Well, you did a simple mistake while creating tween. The third parameter is a dictionary, with the property name as its key and the value as its value. So, to fix your issue, you can do :

-- Line 37, and fix the rest of the lines yourself
local F0OpenP1 = tweenService:Create(F0.Door1.First, info, {CFrame = CFrames.F0D1OP1})

Here, {} will create a table, and CFrame is the property of the Part (I assume that the object is a Part), assigning as the key, and the value as the CFrame in the Dictionary you created.

Lemme know if it helps!

1 comment

0

free upvote

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