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

'Unable to Cast to Dictionary' When Tween Service is Used?

Asked by 5 years ago

I'm trying to make a door sliding script that uses tween service to move the door. But when I do use it, the output says it's unable to cast to dictionary. How could I fix this? Thanks.

local goal = script.Parent.Door.Position + Vector3.new(1,0,0)

local function DoorAnim ()
    local TweenService = game:GetService("TweenService")
    local tweenInfo = TweenInfo.new(5)

local tween = TweenService:Create(script.Parent.Door, tweenInfo, goal)

tween:Play()
end

script.Parent.Model.Part1.SurfaceGui.TextButton.MouseButton1Down:Connect(function()
        DoorAnim()
end)

1 answer

Log in to vote
1
Answered by
chomboghai 2044 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

The problem is that your goal variable is a Vector3 type. It should be a dictionary, with the keys being the properties you want to change and the values being the new values of those properties.

local goal = {
    Position = script.Parent.Door.Position + Vector3.new(1, 0, 0)
}

local function DoorAnim ()
    local TweenService = game:GetService("TweenService")
    local tweenInfo = TweenInfo.new(5)

    local tween = TweenService:Create(script.Parent.Door, tweenInfo, goal)

    tween:Play()
end

script.Parent.Model.Part1.SurfaceGui.TextButton.MouseButton1Down:Connect(function()
        DoorAnim()
end)

Hope this helps! :)

Ad

Answer this question