Why is the remote event failing?
the leaning player is not seen by the other player and I have my remote event running
Also the function to lean in the ‘else’ is not reset
I don’t understand what the problem is, someone could give me a hand
Character started localscript:
-- services
local runService = game:GetService("RunService")
-- 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 = {}
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
-- update function
function renderStepped(dt)
if player.CameraMode == Enum.CameraMode.LockFirstPerson then
print("Correct camera mode.")
-- get useful motor6ds
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)
else
print("Incorrect camera mode.")
--do whatever
local root = motors["RootJoint"]
local leftHip = motors["LeftHip"]
local rightHip = motors["RightHip"]
-- get angles of camera
-- rotate motor6ds
root[1].C0 = root[2] * CFrame.fromEulerAnglesYXZ(0, 0, 0) * CFrame.new(0, 0, 0)
leftHip[1].C0 = leftHip[2] * CFrame.fromEulerAnglesYXZ(0, 0, 0)
rightHip[1].C0 = rightHip[2] * CFrame.fromEulerAnglesYXZ(0, 0, 0)
end
end
-- connections
local connection = runService:BindToRenderStep("updateMotors", Enum.RenderPriority.Character.Value, renderStepped)
-- events
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local lookDownEvent = ReplicatedStorage:WaitForChild("lookDownEvent")
lookDownEvent:FireServer(player, connection)
server script:
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()
print('Connected to server!')
end)
lookDownEvent.OnServerEvent:Connect(function(player, connection)
print('Connected to server!')
print('look down works')
end)