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
Localscript
-- 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
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
-- 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)