Unable To Cast to Dictionary error

hello! im trying to make an openable drawer and i keep getting an error “Unable To Cast To Dictionary” And i dont know what to do. please help!

I will highlight where the error is

local TweenService = game:GetService(“TweenService”)
local Drawer = script.Parent.Parent.Parent

local Opened = {}
Opened.Position = Drawer.TopDrawerOpenPos.Position
Opened.Orientation = Drawer.TopDrawerOpenPos.Orientation

local Closed = {}
Closed.Position = Drawer.TopDrawerClosePos.Position
Closed.Orientation = Drawer.TopDrawerClosePos.Orientation

local Opened = false

script.Parent.Triggered:Connect(function()
– local OpenTween = TweenService:Create(Drawer, TweenInfo.new(0.5), Opened)
– local CloseTween = TweenService:Create(Drawer, TweenInfo.new(0.5), Closed)
if Opened == false then
Opened = true
script.Parent.MaxActivationDistance = 0
workspace.Sfx.OpenDrawer:Play()
OpenTween:Play()
OpenTween.Completed:Wait()
script.Parent.MaxActivationDistance = 5
else
if Opened == true then
Opened = false
script.Parent.MaxActivationDistance = 0
workspace.Sfx.OpenDrawer:Play()
CloseTween:Play()
CloseTween.Completed:Wait()
script.Parent.MaxActivationDistance = 5
end
end
end)

The issue here is you have two variables with the same name, you have Opened which is a table and also a boolean. I would recommend changing it.

so adding Opened and Closed bool values?

nvm i just saw what u meant im kinda dumb thank you so much

1 Like

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