I’ve been trying to do replication for IK since I need the direction players are looking at to be visible to all clients (To allow players to know how aware other players are) I also thought using IK would make it fairly lightweight, A previous attempt to use a Cframe setup didn’t work too well and caused visual issues with animations.
I’ve never ever done Replication before and my attempts aren’t working since I keep getting “did you forget to implement onserverevent?” Errors and the Documentation isn’t helping me very much either.
Here’s the code and some context as it stands right now Some parts are commented out because they just weren’t working at the moment
The RemoteEvent called “AimPass” is parented to the tool
LocalScript (Parented to a tool)
Tool = script.Parent
mouse = game.Players.LocalPlayer:GetMouse()
--local AimPass = script.Parent:WaitForChild("AimPass")
local character = Tool.Parent;
local humanoid = character.Humanoid
local targetPos = humanoid.TargetPoint
local lookAt = (mouse.Hit.p - character.Head.Position).unit
local invTarget = Instance.new("Part")
invTarget.Parent = workspace
invTarget.Size = Vector3.new(0.05,0.05,0.05)
invTarget.Transparency = 1
invTarget.CanCollide = false
invTarget.Anchored = true
local LookAtIK = Instance.new("IKControl")
LookAtIK.Type = Enum.IKControlType.LookAt
LookAtIK.EndEffector = character.Head
LookAtIK.Target = invTarget
LookAtIK.ChainRoot = character.LowerTorso
LookAtIK.SmoothTime = 0.1
LookAtIK.Parent = character.Humanoid
LookAtIK.Enabled = true
LookAtIK.Weight = 0.5
while mouse.Move do
invTarget.Position = mouse.Hit.p
wait(0.25)
-- local aim1 = character.Head.CFrame
-- AimPass:FireServer(aim1)
end
Script (Parented to the same tool)
local AimEvent = script.Parent:WaitForChild("AimPass")
local hed = script.Parent.Parent.Humanoid.Head
local function sightBallsEyedBalls(aim1)
hed.Cframe = aim1
end
AimEvent.OnServerEvent:Connect(sightBallsEyedBalls(pl, aim1))