Script changes player's tilt when ran client-side but doesn't run server-side

  1. What do you want to achieve? Keep it simple and clear!
    I want the HumanoidRootPart’s RootJoint.Transform of the player who fires the RemoteEvent to be replicated server-side so others can see it.

  2. What is the issue? Include screenshots / videos if possible!
    When ran without any events, others cannot see the tilt it but it works. However, when trying to run it server-side, no one can see the tilt at all. Not even you.
    (the test print does work though)

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have searched for solutions but I haven’t found any related to mine. If there is one, please link it! I’d appreciate it.

Tilt Code [LocalScript in StarterCharacterScripts]:

function Lerp(a, b, t)
	return a + (b - a) * t

local STEP = 0.1
local RunService = game:GetService("RunService")

function getYaw(vec)
	return -math.atan2(vec.Z, vec.X) - math.pi/2

local lastFrameDir = script.Parent.HumanoidRootPart.CFrame.lookVector
local lastDir = lastFrameDir
local dir = lastDir
local accum = 0

local rollGoal = 0
local roll = 0
RunService.Stepped:Connect(function(t, dt)
	accum = accum + dt
	lastFrameDir = dir
	dir = script.Parent.HumanoidRootPart.CFrame.lookVector

	local angleDiff = getYaw(dir) - getYaw(lastFrameDir)
	angleDiff = (angleDiff + math.pi/2) % math.pi - math.pi/2
	local sign = angleDiff < 0 and -1 or 1

	if accum > STEP then
		local diff = 1 - lastDir:Dot(dir)
		rollGoal = diff * math.rad(40) * sign

		lastDir = dir
		accum = 0

	roll = Lerp(roll, rollGoal, 0.2)
	--script.Parent.HumanoidRootPart.RootJoint.Transform = script.Parent.HumanoidRootPart.RootJoint.Transform * CFrame.Angles(0, roll, 0)
	game.ReplicatedStorage.ReplicateTilt:FireServer(script.Parent.HumanoidRootPart.RootJoint, roll)			

Event Manager [Script in ServerScriptService]:

	joint.Transform = joint.Transform * CFrame.Angles(0, roll, 0)
	print'success firing event'

If you’re going to link any “unreplicated” screenshots, explaining or some sample code would be appreciated. I don’t think this is the error though, but who knows? :thinking:



Knowing that the test print is functioning, and that it is executing everything correctly, try printing your joint and roll variables. Double check that they’re exactly what they need to be. If you’re not sure what they need to be, go back to your client sided system that worked and print those variables to compare it to.

There’s also some quite hefty performance implications of firing a remote event every frame, on every client, so make sure your game isn’t going to suffer at all from that. That being said though, I’m not really aware of a way to do that any more efficiently off of the top of my head.

Printing out joint and roll variables work. They are printing the same with and without event. They are what they should be. Still having the tilt issue.

How could I make it not run on every frame by the way? I’ve tried something a while ago, but it doesn’t work.

Okay, I’ve done a little looking and I think I’ve found an actual potential solution for you.

Link to topic here.

Hopefully this information is enough for you to get your script up and running again.

It doesn’t work for me. Maybe because of tweening? I might see later.