local runServ = game:GetService("RunService")
local connection
game.ReplicatedStorage.mouseAimMotor.OnServerEvent:Connect(function(plr, disableOrEnable)
--aim mouse function
local function aimMouse()
plr.Character:FindFirstChild("Torso"):FindFirstChild("Right Shoulder").Transform = CFrame.Angles(0, 0, math.pi/2)
end
--starting or stopping the mouse aim
if disableOrEnable then
connection = runServ.Stepped:Connect(aimMouse)
else
connection:Disconnect()
end
end)
That’s the only real important code- this is in a server script in serverscriptservice while the thing calling it is a local script in a tool, calling the event with argument true when tool is equipped and false when its unequipped.
On the server, it works perfectly.
Yet the client sees this…?
I’m assuming it’s because of the order for .stepped, humanoid, and replication in rendering and all that, but I feel like this shouldn’t be happening?
If you can help I’d appreciate it
This has the same implication as the infamous rotating-head-to-align-to-camera thing, which has been asked and answered NUMEROUS times. Just go look those up. In a nutshell, use remotes to animate the limb on both the client and the server. On the client so the player themselves can see the limb moving, on the server so other players can see the limb moving.
This is a bad idea. Why? The method :FindFirstChild() can return nil instead of an instance, and you will run into an error of either attempt to index nil with FindFirstChild or attempt to index nil with Transform. Read this thread to brief yourself on the correct way of doing it because you are giving us a heart attack
So do it separately, but it acts as if its in sync? That was actually my only idea to fix this, good to see there’s really nothing better than that lol
I was gonna say we can be fairly sure when this runs that the player will be there, but I guess if they get blown up or the joint is destroyed it could error- in that case, here’s a question I’ve always had- if a script is waiting for a child that already exists, will it keep waiting, or will it know that it’s already there and move on? Also, if it doesn’t find a child, will anything break, or will the code simply move on?
Unless you specified a timeout, it will just keep waiting and pause the thread. If there is a timeout then it will just return nil when the time is up.
Nuh uh. There is no default timeout. It will just print a warning message if it has been waiting for more than 5 seconds. THIS IS LITERALLY WHAT THEY MEAN BY INFINITE YIELD.