Fireserver issues - Player tilt is not reflected on the server

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

lookDownEvent.OnServerEvent:Connect(function(player)
	print('Connected to server!')
	print('look down works')
end)
print('FINISHED! PARST ARE SHOWING NOW')
lookDownEvent:FireServer()
1 Like

With this change, it should work now.

I made all those changes and it still doesn’t work:

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

Do it like this, like you did in the other script.

image

Going off your image, it’s working, the text before the FireServer() function calls is printed, and then when the corresponding OnServerEvent is fired the text inside of it is printed.

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)
	print('Connected to server!')
	print('look down works')
end)

Line 16 in this script is the print function which prints “Connected to server!” belonging to the lockDownEvent event handler. So the script is working.

I did it and it works it connects to the server but the problem is that the player doesn’t tilt

Where is the player supposed to tilt? The two OnServerEvent events only have print commands inside them.

but I do not understand why it is not seen by other players if I have it connected to the fire server (I mean that other players can see when the player tilt)

Because you need to handle the player’s movement/tilting inside the OnServerEvent events for it to be reflected across the whole server so other’s can see.

And how could I do that :open_mouth: ? :cold_sweat:

Here’s how you can achieve the desired result (I will use pseudocode for simplicity)

  1. Calculate the tilt angles and fire event to the server
-- Step 1. Local Script
local tiltAngle = 2+2
lookDownEvent:FireServer(tiltAngle)
  1. Process the event and send it to all players
-- Step 2. Server Script
local function onPlayerTilt(playerTilting, tiltAngle)
     -- Don't forget to check if tiltAngle value is valid (hackers can send any values)
    lookDownEvent:FireAllClients(playerTilting, tiltAngle)
end
lookDownEvent:OnServerEvent:Connect(onPlayerTilt)
  1. Tilt the tilting player on client side
-- Step 3. Local Script
local function onPlayerTilt(tiltingPlayer, tiltAngle)
    tiltingPlayer:SetTiltAngle(tiltAngle)
end
lookDownEvent:OnClientEvent:Connect(onPlayerTilt)

Note that you will have a slight delay for your own tilting, you can avoid that by doing the tilting code for yourself separately and add this code in step 3 to avoid running code two times

-- Step 3. Local Script
local function onPlayerTilt(tiltingPlayer, tiltAngle)
    if tiltingPlayer == localPlayer then return end
    tiltingPlayer:SetTiltAngle(tiltAngle)
end
lookDownEvent:OnClientEvent:Connect(onPlayerTilt)