I’m making something like a dash and I’m trying to move forward using tween service. However, please solve the problem that it does not work with the “Unable to cast to Dictionary” message.
local Slide = Instance.new("VectorForce")
local A0 = Instance.new("Attachment", Char.HumanoidRootPart)
Slide.RelativeTo = "World"
Slide.Attachment0 = A0
Slide.Force = Char.HumanoidRootPart.CFrame.LookVector * Vector3.new(SlideForce, 0, SlideForce)
local T = Hum.Animator:LoadAnimation(SlideAnimation)
T:Play()
Slide.Parent = Char.HumanoidRootPart
Slide.Enabled = true
local tweenInfo = TweenInfo.new(0.0001, Enum.EasingStyle.Exponential, Enum.EasingDirection.InOut)
local tween = game:GetService('TweenService'):Create(Slide, tweenInfo, { Char.HumanoidRootPart.CFrame.LookVector * Vector3.new(SlideForce, 0, SlideForce) })
tween:Play()
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.
You are trying to tween the VectorForce object, which is not a valid object to apply a Tween to.
Instead, you should be tweening a property of a valid object. Since you are applying force to the character, you can try tweening the Force property of the VectorForce object. Here’s the corrected code:
local Slide = Instance.new("VectorForce")
local A0 = Instance.new("Attachment", Char.HumanoidRootPart)
Slide.RelativeTo = "World"
Slide.Attachment0 = A0
Slide.Force = Char.HumanoidRootPart.CFrame.LookVector * Vector3.new(SlideForce, 0, SlideForce)
local T = Hum.Animator:LoadAnimation(SlideAnimation)
T:Play()
Slide.Parent = Char.HumanoidRootPart
Slide.Enabled = true
local tweenInfo = TweenInfo.new(0.0001, Enum.EasingStyle.Exponential, Enum.EasingDirection.InOut)
local targetForce = Char.HumanoidRootPart.CFrame.LookVector * Vector3.new(SlideForce, 0, SlideForce)
local tween = game:GetService('TweenService'):Create(Slide, tweenInfo, { Force = targetForce })
tween:Play()