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

Tweening parts with CFrame showing 'Unable to cast Dictionary' error?

Asked by 3 years ago

So, I wanted to make tweening the character's LowerTorso 30 studs forward. It shall tween when a LocalScript fires an event which is child of the script called ForceA. But it keeps saying an error message "Unable to cast Dictionary" in the output. The script for tweening is in the StarterCharacterScripts.

The TweenInfo I have used is:

local tweeninfo = TweenInfo.new(
5,Enum.EasingStyle.Sine,
Enum.EasingDirection.Out, 
0, 
false, 
0)

When a LocalScript fires the ForceA event under the script, the character is supposed to tween 30 studs forward. The LowerTorso has joints that can move the full character. Instead it shows the error message.

It says the error is caused on line 5 of the function code below:

local lowertorso = Script.Parent.LowerTorso

script.ForceA.OnServerEvent:Connect(function()
    local movingpos = lowertorso.CFrame * CFrame.new(0, 0, -30)
    local tween = TweenService:Create(lowertorso, tweeninfo, movingpos)
    tween:Play()
end

I have used LookVector() property and I am pretty sure it's a CFrame position. Please help me out for this. I need this so much.

0
Your "Script" should be "script" and i not sure if it is also because the Torso has not loaded in. So, try :WaitForChild("LowerTorso") to make sure that the torso has successfully loaded before going to the other lines of codes. XviperIink 428 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

Create() has three params, the instance you want to tween, tweeninfo, and the properties you want to change in a dict, with as key the name of the prop and as value the value. atm you are just passing the value not a dict

so do this instead

local lowertorso = Script.Parent.LowerTorso

script.ForceA.OnServerEvent:Connect(function()
    local movingpos = lowertorso.CFrame * CFrame.new(0, 0, -30)
    local tween = TweenService:Create(lowertorso, tweeninfo, {CFrame = movingpos})
    tween:Play()
end
0
Thanks, that helped a lot Shounak123 461 — 3y
Ad

Answer this question