Unable to cast value to Object

So I am trying to make a system where you can punch people and it sends them backwards. When I try to play the tween on line 7 I keep getting an error saying “Unable to cast value to Object”.

Here is the code:

game.ReplicatedStorage.CheckOtherPlr.OnServerEvent:Connect(function(plr, plr2Check: Player)
	game.ReplicatedStorage.CheckOtherPlr:FireClient(plr2Check, plr)
end)

game.ReplicatedStorage.PunchPlr.OnServerEvent:Connect(function(plr, plrPunched)
	local rootpart = plrPunched.Character.HumanoidRootPart
	local twn = game:GetService("TweenService"):Create(rootpart.CFrame, TweenInfo.new(1.25, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), { Position = Vector3.new(rootpart.CFrame.Position.X, rootpart.CFrame.Position.Y, rootpart.CFrame.Position.Z + 10)})
	twn:Play()
end)

The first value that should be passed is an instance, but you’re passing rootpart.CFrame which is a value. This should fix the problems:

local twn = game:GetService("TweenService"):Create(rootpart, TweenInfo.new(1.25, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {CFrame = CFrame.new(rootpart.CFrame.X, rootpart.CFrame.Y, rootpart.Z + 10)})
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.