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

Unable to cast to dictionary error when using TweenService?

Asked by 7 years ago

So I'm trying to make a sliding door, and I've managed to make it open, but closing it again doesn't seem to work.

This is the bit of the code that opens the door

local tweenService = game:GetService("TweenService")

local door1 = script.Parent.Parent.door1
door1.Position = Vector3.new(-33.5, 7.2, -16.2)

local door2 = script.Parent.Parent.door2
door2.Position = Vector3.new(-24.1, 7.2, -16.2)

local goal1 = {}
goal1.Position = Vector3.new(-42.9, 7.2, -16.2)

local goal2 = {}
goal2.Position = Vector3.new(-14.7, 7.2, -16.2)

local tweenInfo = TweenInfo.new(3)

local tween1 = tweenService:Create(door1, tweenInfo, goal1)
local tween2 = tweenService:Create(door2, tweenInfo, goal2)

script.Parent.Touched:connect(function(door)
    tween1:Play()
    tween2:Play()
end)

And then to close the door I wrote this:

local tween3 = tweenService:Create(goal1, tweenInfo, door1)
local tween4 = tweenService:Create(goal2, tweenInfo, door2)

script.Parent.Touched:connect(function(door)
    tween3:Play()
    tween4:Play()
end)

But this doesn't work. Instead I get the "Unable to cast to dictionary" error that links to the "tween3" local.

0
do local goal = {Position = Vector3.new()} abnotaddable 920 — 7y
0
instead abnotaddable 920 — 7y

Answer this question