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

Tweening a door is not working - Unable to cast to dictonary- can somone explain?

Afternoon Fellow scripters - hope your having a lovely day! I was writing a piece of code for a door and i do not understand Unable to cast to dictonary. - Can someone go though it for me

;goku :D

local door = game.Workspace.Wawawasputin
local part = game.Workspace.CAta
local TweenSevers = game:GetService("TweenService")
local tweenionfo = TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0)
local tweenposopen = {CFrame.new(3592.667, 3876.391, -2757.274)}
local tweenposclose = {CFrame.new(3603.981, 3876.391, -2768.587)}
local tweenopen = TweenSevers:Create(tweenionfo,tweenposopen,door)
local tweenclose = TweenSevers.Create(tweenionfo,tweenposclose,door)

part.Touched:Connect(function()
	tweenopen:Play()
	wait(2)
	tweenclose:Play()
end)

2 comments

0

I c why it didn't work, I edited my code

0

i tried rewriting it and it still doesnt work - nvm

2 answers

It errors because you're casting an array to a dictionary, meaning: you're passing an array when it is meant to be a dictionary.

The way TweenService:Create works is that it uses keys as the property to change and the value as the amount to tween to.

So, here's a solution for you:

local door = game.Workspace.Wawawasputin
local part = game.Workspace.CAta
local TweenSevers = game:GetService("TweenService")
local tweenionfo = TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0)
local tweenposopen = {CFrame = CFrame.new(3592.667, 3876.391, -2757.274)}
local tweenposclose = {CFrame = CFrame.new(3603.981, 3876.391, -2768.587)}
local tweenopen = TweenSevers:Create(door, tweenionfo, tweenposopen)
local tweenclose = TweenSevers:Create(door, tweenionfo, tweenposclose)

part.Touched:Connect(function()
    tweenopen:Play()
    wait(2)
    tweenclose:Play()
end)

4 comments

0

not working ;-;

0

post errors

0

um you are using TweenSevers:Create and TweenSevers.Create

0

same "unable to cast to dictonary"

The syntax for TweenService:Create() is: 'Object, TweenInfo, Goal' not: 'TweenInfo, Goal, Object'. That is why it is erroring. (And you made a typo TweenSevers.Create instaid of TweenSevers:Create

local door = game.Workspace.Wawawasputin
local part = game.Workspace.CAta
local TweenSevers = game:GetService("TweenService")
local tweenionfo = TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0)
local tweenposopen = {CFrame.new(3592.667, 3876.391, -2757.274)}
local tweenposclose = {CFrame.new(3603.981, 3876.391, -2768.587)}
local tweenopen = TweenSevers:Create(door,tweenionfo,tweenposopen)
local tweenclose = TweenSevers:Create(door,tweenionfo,tweenposclose)

part.Touched:Connect(function()
    tweenopen:Play()
    wait(2)
    tweenclose:Play()
end)

If that doesn't work it is problably another typo or me being stupid.

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