Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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.

1 comment

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.

1 answer

✓ Accepted answer

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

1 comment

0

Thanks, that helped a lot

This discussion is preserved as it was. New answers, comments, and votes are closed.