Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 5 years ago

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)
0
I c why it didn't work, I edited my code Rare_tendo 3000 — 5y
0
i tried rewriting it and it still doesnt work - nvm ScriptingNubs 55 — 5y

2 answers

Log in to vote
0
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

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)
0
not working ;-; ScriptingNubs 55 — 5y
0
post errors Rare_tendo 3000 — 5y
0
um you are using TweenSevers:Create and TweenSevers.Create theking48989987 2147 — 5y
0
same "unable to cast to dictonary" ScriptingNubs 55 — 5y
Ad
Log in to vote
0
Answered by
jaschutte 324 Moderation Voter
5 years ago

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.

Answer this question