I had to re-make the post because the first one died ignored
Hi, hope you are having a good day
Well, a bit of context on my problem
Im making a shooter game, and i decided to use a torso follows mouse script so weapon shooting direction doesnt look weird when aiming to the floor or the sky
The problem is, its only client-sided so no other players see your torso facing mouse direction.
Because of that, i decided to make it server-sided using remotes
However, that gives me this weird result, the torso is stuck in that orientation and doesnt follows the mouse.
Buuut, it doesnt throws any error
So, what is happening here? Its pretty much the same as the client-side script
Here are the scripts
Oiginal client-sided-only script
local RunService = game:GetService("RunService")
local Player = game.Players.LocalPlayer
local PlayerMouse = Player:GetMouse()
local Character = Player.Character or Player.CharacterAdded:Wait()
local Head = Character:WaitForChild("Head")
local Neck = Head:WaitForChild("Neck")
local Arm = Character:WaitForChild("LowerTorso")
local Torso = Character:WaitForChild("UpperTorso")
local Shoulder = Torso:WaitForChild("Waist")
local Humanoid = Character:WaitForChild("Humanoid")
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local NeckOriginC0 = Neck.C0
local ShoulderOriginC0 = Shoulder.C0
Neck.MaxVelocity = 1/3
RunService.RenderStepped:Connect(function()
if Character:FindFirstChild("UpperTorso") and Character:FindFirstChild("Head") then
local ArmLookVector = Arm.CFrame.lookVector
local HeadPosition = Head.CFrame.p
if Neck and Shoulder then
local Point = PlayerMouse.Hit.p
local Distance = (Head.CFrame.p - Point).magnitude
local Difference = Head.CFrame.Y - Point.Y
Shoulder.C0 = Shoulder.C0:lerp(ShoulderOriginC0 * CFrame.Angles(-(math.asin(Difference / Distance)), (((HeadPosition - Point).Unit):Cross(ArmLookVector)).Y, 0), .5 / 2)
end
end
end)
Now, the edited localscript so it can work with the remote
local RunService = game:GetService("RunService")
local Player = game.Players.LocalPlayer
local PlayerMouse = Player:GetMouse()
local mouseHit = PlayerMouse.Hit
local Character = Player.Character or Player.CharacterAdded:Wait()
local Head = Character:WaitForChild("Head")
local Neck = Head:WaitForChild("Neck")
local Arm = Character:WaitForChild("LowerTorso")
local Torso = Character:WaitForChild("UpperTorso")
local Shoulder = Torso:WaitForChild("Waist")
local Humanoid = Character:WaitForChild("Humanoid")
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local NeckOriginC0 = Neck.C0
local ShoulderOriginC0 = Shoulder.C0
Neck.MaxVelocity = 1/3
RunService.RenderStepped:Connect(function()
script.Parent.FMouse:FireServer(Player, mouseHit, Character, Head, Neck, Arm, Torso, Shoulder, Humanoid, HumanoidRootPart, NeckOriginC0, ShoulderOriginC0)
end)
And last, the server script
script.Parent.FMouse.OnServerEvent:Connect(function(p, Player, mouseHit, Character, Head, Neck, Arm, Torso, Shoulder, Humanoid, HumanoidRootPart, NeckOriginC0, ShoulderOriginC0)
if Character:FindFirstChild("UpperTorso") and Character:FindFirstChild("Head") then
local ArmLookVector = Arm.CFrame.lookVector
local HeadPosition = Head.CFrame.p
if Neck and Shoulder then
local point = mouseHit.p
local Distance = (Head.CFrame.p - point).magnitude
local Difference = Head.CFrame.Y - point.Y
Shoulder.C0 = Shoulder.C0:lerp(ShoulderOriginC0 * CFrame.Angles(-(math.asin(Difference / Distance)), (((HeadPosition - point).Unit):Cross(ArmLookVector)).Y, 0), .5 / 2)
end
end
end)
Thats it, if you need any other details, feel free to ask for them. I hope you can help me, thanks.