-
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.
-
What is the issue? “Unable to cast Instance to CoordinateFrame” when trying to lerp
-
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)