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

TweenService returned error "Unable to cast to Dictionary" on line 39.?

Asked by 2 years ago
Edited 2 years ago

I am working on a machine, and got this error when making all 10 pins animate.

ts = game:GetService("TweenService")
game.Workspace.TouchPart.Touched:Connect(function(hit)
    if hit.Name == "Rekt" then
        wait(1)
        for i,v in pairs(d) do
            v.Anchored = true
        wait(1)
            eg = {}
            eg.Position = Vector3.new(41.413, 10.676, 164.464)
            eg.Orientation = Vector3.new(0,90,0)
            local eg1 = {}
            eg1.Position = Vector3.new(43.331, 10.676, 157.219)
            eg1.Orientation = Vector3.new(0,90,0)
            local eg2 = {}
            eg2.Position = Vector3.new(45.215, 10.676, 164.464)
            eg2.Orientation = Vector3.new(0,90,0)
            local eg3 = {}
            eg3.Position = Vector3.new(45.219, 10.676, 159.899)
            eg3.Orientation = Vector3.new(0,90,0)
            local eg4 = {}
            eg4.Position = Vector3.new(46.937, 10.676, 162.233)
            eg4.Orientation = Vector3.new(0,90,0)
            local eg5 = {}
            eg5.Position = Vector3.new(41.303, 10.676, 159.899)
            eg5.Orientation = Vector3.new(0,90,0)
            local eg6 = {}
            eg6.Position = Vector3.new(37.991, 10.676, 164.464)
            eg6.Orientation = Vector3.new(0,90,0)
            local eg7 = {}
            eg7.Position = Vector3.new(48.437, 10.676, 164.464)
            eg7.Orientation = Vector3.new(0,90,0)
            local eg8 = {}
            eg8.Position = Vector3.new(43.326, 10.676, 162.233)
            eg8.Orientation = Vector3.new(0,90,0)
            local eg9 = {}
            eg9.Position = Vector3.new(39.646, 10.676, 162.233)
            eg9.Orientation = Vector3.new(0,90,0)
            local Tweeninfo = TweenInfo.new(1.5, Enum.EasingStyle.Linear)
            local t1 = ts:Create(script.Parent.Model.Pin1, Tweeninfo, eg.Position) -- line of error.
            local t2 = ts:Create(script.Parent.Model.Pin2, Tweeninfo, eg1.Position)
            local t3 = ts:Create(script.Parent.Model.Pin3, Tweeninfo, eg2.Position)
            local t4 = ts:Create(script.Parent.Model.Pin4, Tweeninfo, eg3.Position)
            local t5 = ts:Create(script.Parent.Model.Pin5, Tweeninfo, eg4.Position)
            local t6 = ts:Create(script.Parent.Model.Pin6, Tweeninfo, eg5.Position)
            local t7 = ts:Create(script.Parent.Model.Pin7, Tweeninfo, eg6.Position)
            local t8 = ts:Create(script.Parent.Model.Pin8, Tweeninfo, eg7.Position)
            local t9 = ts:Create(script.Parent.Model.Pin9, Tweeninfo, eg8.Position)
            local t10 = ts:Create(script.Parent.Model.Pin10, Tweeninfo, eg9.Position)
            t1:Play()
            t2:Play()
            t3:Play()
            t4:Play()
            t5:Play()
            t6:Play()
            t7:Play()
            t8:Play()
            t9:Play()
            t10:Play()
        end
    end
end)
1
remove .Position from eg1 through eg9 from lines 39-48 greatneil80 2647 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago

The third parameter for TweenService:Create() is a dictionary containing the end goal for the tween. You made dictionaries called eg1, eg2 etc. But eg.Position is not a dictionary. For the create on that line you would need to put

local t1 = ts:Create(script.Parent.Model.Pin1, Tweeninfo, eg)

That will change the position and orientation to the ones you set.

If you only want to change the position, then you can make a new dictionary inside of the create constructor, the create function would look like

local t1 = ts:Create(script.Parent.Model.Pin1, Tweeninfo,{eg.Position = Vector3.new(41.413, 10.676, 164.464)})

Just put in the position directly with curly brackets

0
While this does move the pins, They are flinging all over the place when they go up into the finish position. bittyboy1234 91 — 2y
0
all the parts seem to be flying everywhere, with some even getting destroyed, Is there an email I can send a video to? bittyboy1234 91 — 2y
0
are you sure the parts are anchored? SuperSM1 67 — 2y
0
yessir bittyboy1234 91 — 2y
Ad

Answer this question