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)
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)
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.