Fireserver issues - Player tilt is not reflected on the server

The tilt of my character is not reflected in the server (I want all the players to be able to see that the player is tilt) someone could give me a hand, it took days and I have not been able to solve it :frowning:

Localscript

image

-- services
local runService = game:GetService("RunService")
local lookDownEvent = game.ReplicatedStorage.lookDownEvent

-- player stuff
local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local character = player.Character

-- character stuff
local humanoid = character:WaitForChild("Humanoid")
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
local torso = character:WaitForChild("Torso")



-- put all motors inside the character into a dictionary for easy access
-- remove spaces from motor names
local motors = {}



local function iteraCharParts()
	for _, motor in pairs(character:GetDescendants()) do
		if motor:IsA("Motor6D") then
			-- gives a table with the motor as the first index, and the motor initial c0 as the second
			motors[string.gsub(motor.Name, "%s+", "")] = {motor, motor.C0}
		end
	end
end

iteraCharParts()
runService:BindToRenderStep('updating', 100, function()
	local root = motors["RootJoint"]
	local leftHip = motors["LeftHip"]
	local rightHip = motors["RightHip"]
	-- get angles of camera
	local y, x, z = camera.CFrame:ToEulerAnglesYXZ()
	local groundOffset = math.abs(0.5 * torso.Size.Y - 0.5 * torso.Size.Z) * math.abs(math.sin(y))
	-- rotate motor6ds
	root[1].C0 = root[2] * CFrame.fromEulerAnglesYXZ(-y, 0, 0) * CFrame.new(0, 0, -groundOffset)
	leftHip[1].C0 = leftHip[2] * CFrame.fromEulerAnglesYXZ(0, 0, y)
	rightHip[1].C0 = rightHip[2] * CFrame.fromEulerAnglesYXZ(0, 0, -y)
	print('FINISHED! PARST ARE SHOWING NOW')
	lookDownEvent:FireServer(player)
end)

Server Script

image


local ReplicatedStorage = game:GetService("ReplicatedStorage")
local runAnimEvent = ReplicatedStorage:WaitForChild("PlayRunAnim")
local lookDownEvent = ReplicatedStorage:WaitForChild("lookDownEvent")

local players = game:GetService("Players")
local player = players.LocalPlayer



runAnimEvent.OnServerEvent:Connect(function(player)
	print('Connected to server!')
end)

lookDownEvent.OnServerEvent:Connect(function(player, connection)
	print('Connected to server!')
	print('look down works')
end)

My other localscript

image

-- SERVICES
local players = game:GetService("Players")
local uis = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")

-- GAME VARIABLES
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:wait()
local humanoid = character:WaitForChild("Humanoid")
local camera = workspace.CurrentCamera
local runAnimEvent = ReplicatedStorage:WaitForChild("PlayRunAnim")
local normalCamera = camera.CFrame:ToOrientation()

-- ANIMATIONS VARIABLES
local runAnimation = ReplicatedStorage:WaitForChild("runAnimation")
local runAnimationTrack = humanoid.Animator:LoadAnimation(runAnimation) 
runAnimationTrack.Looped = true

-- GLOBAL VARIABLES
local isClassicCamera = true
local isLimitCamera = true

-- Getting attributes
local minZoomAttribute_FPS = game.ReplicatedStorage.zoomAttributes_Classic:GetAttribute("minZoom")
local maxZoomAttribute_FPS = game.ReplicatedStorage.zoomAttributes_Classic:GetAttribute("maxZoom")

local minCameraAttribute_FPS = game.ReplicatedStorage.limitCameraAttributes_FPS:GetAttribute("minCamera")
local maxCameraAttribute_FPS = game.ReplicatedStorage.limitCameraAttributes_FPS:GetAttribute("maxCamera")

local xAxisPlayerCameraAttribute = game.ReplicatedStorage.controllerPlayerCamera:GetAttribute("Xaxis")
local yAxisPlayerCameraAttribute = game.ReplicatedStorage.controllerPlayerCamera:GetAttribute("Yaxis")
local zAxisPlayerCameraAttribute = game.ReplicatedStorage.controllerPlayerCamera:GetAttribute("Zaxis")

local xAxisCameraOffsetAttribute = game.ReplicatedStorage.CameraOffsetAttributes:GetAttribute("Xaxis")
local yAxisCameraOffsetAttribute = game.ReplicatedStorage.CameraOffsetAttributes:GetAttribute("Yaxis")
local zAxisCameraOffsetAttribute = game.ReplicatedStorage.CameraOffsetAttributes:GetAttribute("Zaxis")

-- FUNCTIONS

-- zoom out function
function ZoomOut(minZoomDistance, maxZoomDistance)
	player.CameraMode = Enum.CameraMode.Classic
	player.CameraMinZoomDistance = minZoomDistance
	player.CameraMaxZoomDistance = maxZoomDistance
end

local normalCamera = camera.CFrame:ToOrientation()

-- Camera limitations function
local function limitCameraUpDown(minVal, maxVal)
	RunService:BindToRenderStep("UpdateLoop", Enum.RenderPriority.Camera.Value, function()
		local minCameraVal = minVal
		local maxCameraVal = maxVal
		local rX, rY, rZ = camera.CFrame:ToOrientation()
		local limX = math.clamp(math.deg(rX), minCameraVal, maxCameraVal)
		camera.CFrame = CFrame.new(camera.CFrame.p) * CFrame.fromOrientation(math.rad(limX), rY, rZ)
	end)
end

local function removeLimitCameraUpDown()
	RunService:UnbindFromRenderStep("UpdateLoop")
end

-- Anti trans parts function
function antiTrans(part)
	if part and part:IsA("BasePart") and(part.Name=="Left Arm"  or part.Name=="Right Arm" or part.Name=="Left Leg" or part.Name=="Right Leg") then
		part.LocalTransparencyModifier = part.Transparency
		part.Changed:connect(function (property)    
			part.LocalTransparencyModifier = part.Transparency
		end)
	end
end

-- Game start with FPS MODE ACTIVATED
player.CameraMode = Enum.CameraMode.LockFirstPerson

uis.MouseIconEnabled = false
for _,v in pairs(character:GetChildren()) do
	antiTrans(v, true)
end

limitCameraUpDown(minCameraAttribute_FPS, maxCameraAttribute_FPS) -- -34, 150

-- Change camera by pressing a key
uis.InputBegan:Connect(function(input)

	-- Activate camera buttons
	if input.KeyCode == Enum.KeyCode.T and isClassicCamera == true then
		print('Classic Mode Activated')
		-- do something
		ZoomOut(minZoomAttribute_FPS, maxZoomAttribute_FPS) -- 10, 70
		removeLimitCameraUpDown()
		uis.MouseIconEnabled = true
		
		isClassicCamera = false

	elseif input.KeyCode == Enum.KeyCode.T and isClassicCamera == false then
		print('FPS Mode Activated')
		-- do something
		player.CameraMode = Enum.CameraMode.LockFirstPerson
		player.Character.Humanoid.CameraOffset = Vector3.new(xAxisCameraOffsetAttribute, yAxisCameraOffsetAttribute, zAxisCameraOffsetAttribute) -- 0, -0.4, -0.2
		limitCameraUpDown(minCameraAttribute_FPS, maxCameraAttribute_FPS) -- -34, 150
		uis.MouseIconEnabled = false

		if isClassicCamera == false then
			for _,v in pairs(character:GetChildren()) do
				antiTrans(v, true)
			end
		end

		isClassicCamera = true
	end

	-- Run animation play
	if input.KeyCode == Enum.KeyCode.W or input.KeyCode == Enum.KeyCode.S or input.KeyCode == Enum.KeyCode.A or input.KeyCode == Enum.KeyCode.D then
		runAnimationTrack:Play()
		runAnimEvent:FireServer()
	end
end)

-- Ended of key
uis.InputEnded:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.W or input.KeyCode == Enum.KeyCode.S or input.KeyCode == Enum.KeyCode.A or input.KeyCode == Enum.KeyCode.D then
		runAnimationTrack:Stop()
		runAnimEvent:FireServer()
	end
end)
1 Like

FireServer() should have corresponding OnServerEvent events, I can’t seem to locate any in your scripts.

in the localscript is here the fireserver:

I see where you’ve fired the server but you need OnServerEvent event listeners to handle the server being fired.

Oops sorry copy wrong, I’m going to paste

Server script updated :smiley:

1 Like

lookDownEvent:FireServer(player)
Doesn’t need the player argument.

As such, you can remove the parameter named “connection” from the connected function.

lookDownEvent.OnServerEvent:Connect(function(player)
	print('Connected to server!')
	print('look down works')
end)

In your server script you need a OnServerEvent. This fires only once FireServer() is executed.

This dev hub article should help with explaining there are sections for RemoteEvents and RemoteFunctions. Also sections for firing client and firing server.

You will see that you need this code on the server:
remoteEvent.OnServerEvent:Connect()

Basically you will need to put your code you want to fire on the server inside of this function.

This post came a little late unfortunately.

1 Like

Already did check the script updated

1 Like
runAnimEvent.OnServerEvent:Connect(function(player)
	print('Connected to server!')
end)

lookDownEvent.OnServerEvent:Connect(function(player, connection)
	print('Connected to server!')
	print('look down works')
end)

Do any of these get printed? Check my post above also.

i tried it and still not working :confused:

Does the print inside the runAnimEvent handler get executed?

If the animation works and runs correctly but the other one does not work

That’s lookDownEvent, which of the 2 FireServer functions isn’t working?

print('FINISHED! PARST ARE SHOWING NOW')
lookDownEvent:FireServer()

Does this print execute before the FireServer attempt? If not then you likely have some other issue.

image

Yes, look at the output, it’s kind of strange but it doesn’t work :frowning:

Remove the player parameter like I mentioned and make sure the following is a correct reference (correct spelling, capitalisation etc.):

local lookDownEvent = game.ReplicatedStorage.lookDownEvent

If it is correct change it to:

local lookDownEvent = game.ReplicatedStorage:WaitForChild("lookDownEvent")

something like this?

image

i juwsut changed this part:
image