"Unable to cast Instance to CoordinateFrame"

  1. What do you want to achieve? Tween / Lerp another’s whole right arm position and rotation. So I thought using CFrame would be the best option for it.

  2. What is the issue? “Unable to cast Instance to CoordinateFrame” when trying to lerp
    image

  3. What solutions have you tried so far? Trying TweeningService but it gives a similar error

Basically, I reproduce the inversed kinematics in a local script and then replicate it to the server (sending the CFrames of each part of the arm to every player locally in another local script) so other players can see it.

First Local Script:

local ExternalLooks_folder = game.ReplicatedStorage:WaitForChild('RemoteEvents').ExternalLooks

mouse.Move:Connect(function()
	local posX, posY, posZ = mouse.Hit.X, mouse.Hit.Y, mouse.Hit.Z	
	local targetPos		= Vector3.new(posX, posY, posZ)
	Target.Position = targetPos
	Ikcontrol.Target = Target
	ExternalLooks_folder.LookArm:FireServer(player, character:WaitForChild('RightUpperArm').CFrame, character:WaitForChild('RightLowerArm').CFrame, character:WaitForChild('RightHand').CFrame)
end)

ServerScript:

local ExternalLooks_folder = game.ReplicatedStorage:WaitForChild('RemoteEvents').ExternalLooks

ExternalLooks_folder.LookArm.OnServerEvent:Connect(function(player, RightUpperArmCFRAME, RightLowerArmCFRAME, RightHandCFrame)
	for _, v in pairs(game.Players:GetChildren()) do
		if v ~= player then --If the current player is not the one that just moved his arm then:
			ExternalLooks_folder.LookArm:FireClient(v, player, RightUpperArmCFRAME, RightLowerArmCFRAME, RightHandCFrame)
		end
	end
end)

Local Script after server replication:

local ExternalLooks_folder = game.ReplicatedStorage:WaitForChild('RemoteEvents').ExternalLooks

ExternalLooks_folder.LookArm.OnClientEvent:Connect(function(otherPlayer, RightUpperArmCFRAME, RightLowerArmCFRAME, RightHandCFrame)
	local RightUpperArm = otherPlayer.Character:WaitForChild('RightUpperArm')
	local RightLowerArm = otherPlayer.Character:WaitForChild('RightLowerArm')
	local RightHand = otherPlayer.Character:WaitForChild('RightHand')

	if RightUpperArm then
		RightUpperArm.CFrame:Lerp(RightUpperArmCFRAME, 1)
		RightLowerArm.CFrame:Lerp(RightLowerArmCFRAME, 1)
		RightHand.CFrame:Lerp(RightHandCFrame, 1)
	end
end)

First of all, it shows which line of code the issue comes from, though line 57 if im not mistaken.
You can also click on it to find the line quickly, then it also shows the name of the mistake.

Now to explain what the error means, you send through an Instance somewhere, when you had to send a CoordinateFrame through.

Well now while reading your script, I notice the issue.

When you fire from client -> server a new parameter gets added on the first row the player parameter, but what you’re doing is manually adding that parameter yourself:

Just remove the player argument here first of all.

:FireServer and :FireClient are basically polar opposites, you do know how :FireClient works, you put in the player object of whichever client you want to send this through, but what you forgot is when you fire :FireServer automatically a new parameter gets added from the player who send it.

So “RightUpperArmCFRAME” would become the manual player… I didn’t know about that, thank you for your help! After trying your reply I noticed that it’s strange that now it no longer has any type of errors but it just doesn’t lerp the otherplayer’s arm. Do you know what may be causing that? If you don’t, anyways I really appreciate your help because today I learned something new!

Well not quite, what I suggest doing in this case is spamming prints everywhere to see what the problem is, though it might get quite a lot to take in when you do.

Also mark a post as solution so that this post gets archived.

1 Like

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