Unable to cast co-ordinate frame?

I have a script which fires a model to the players position called BonePush, I’ve never had this error before but now I suddenly am?

The error is on line 47.

local tool = script.Parent
repeat task.wait() until script.Parent
local targetfound = false
repeat task.wait() until script.Parent.Name ~= "SansAttacks"
local mag = 4000
local player = game.Players:GetPlayerFromCharacter(script.Parent.Parent)

local players = game.Players:GetChildren()
local range = 300
local lastmag= 1000
local mTorso = script.Parent.Parent:FindFirstChild("Torso")
local mHum = script.Parent:FindFirstChild("Humanoid")
for i=1,#players do
	if players[i].Character then
		local char = players[i].Character
		if char:FindFirstChild("Torso") then
			local Torso = char:FindFirstChild("Torso")
			local mag = (Torso.Position - script.Parent.Torso.Position).magnitude
			if mag<=range then
				if char.Name ~= script.Parent.Parent then
					if mag < lastmag then
						mag = (Torso.Position - script.Parent.Torso.Position).magnitude
						lastmag = mag
						TargetPosition = Vector3.new(Torso.Position.x,Torso.Position.y -1,Torso.Position.z)
						targetfound = true

end -- end of for loop

if targetfound == true then

	local BoneType = 1
	local Bones = game.ServerStorage.SansAttacks.BlueBonePush.BluePush:Clone()

	Bones.Owner.Value = script.Parent.Name
	Bones.Parent = game.Workspace
	Bones:SetPrimaryPartCFrame(TargetPosition.X,TargetPosition.Y ,TargetPosition.Z)
	local Center = Bones.CFrame
	local pos1 = Bones.Position
	local DirectionVector3 =  Center:vectorToWorldSpace(Vector3.new(0,0,0)) -- (+)left or (-)right

	if BoneType == 1 then
		DirectionVector3 =  Center:vectorToWorldSpace(Vector3.new(0,0,-30))
	Bones:SetPrimaryPartCFrame(Vector3.new(TargetPosition.X, TargetPosition.Y ,TargetPosition.Z) + DirectionVector3*2)

	local slope = pos1
	local	 magnitude = (pos1).magnitude
	local	angleOfVelocity = slope/magnitude
	local	 Velocity = angleOfVelocity*100

	Bones.BodyVelocity.Velocity = Velocity *.25
	Bones.Script.Disabled =false
	Bones.Decay.Disabled =false


Help would be greatly appreciated thank you!

In the bones model, there would need to be at least a part called HumanoidRootPart (probably have that as the middle part). So then instead of local Center = Bones.CFrame you should put in:

local Center = Bones:GetPrimaryPartCFrame()
Hope this helps!


This still doesn’t work as the error is on the line before that, And it still keeps saying unable to get co-ordinate frame


SetPrimaryPartCFrame expects a CFrame, not 3 numbers or a Vector3. It should be:

Bones:SetPrimaryPartCFrame(CFrame.new(TargetPosition.X, TargetPosition.Y ,TargetPosition.Z))

It works I think? But now I am getting this error…

I don’t know why though…