When I made torso follows to the camera it looked normal in the client, but when I made it through events on the server it became like this…
I think it’s a problem in While or in the server.
And that’s my code
ServerScriptStorage
game.ReplicatedStorage.HandleCameraProperties.OnServerEvent:Connect(function(playerfired, camCFrame, player)
local character = player
local root = character:WaitForChild("HumanoidRootPart")
local neck = character:FindFirstChild("Neck", true)
local waist = character:FindFirstChild("Waist", true)
local yOffsetNeck = neck.C0.Y
local yOffsetWaist = waist.C0.Y
local CFNew, CFAng, asin = CFrame.new, CFrame.Angles, math.asin
while true do
wait()
local cameraDirection = root.CFrame:toObjectSpace(camCFrame).lookVector
if neck then
neck.C0 = CFNew(0, yOffsetNeck / 1.4, 0) * CFAng(0, -asin(cameraDirection.x) / 1.4, 0) * CFAng(asin(cameraDirection.y) / 1.4, 0, 0)
end
if waist then
waist.C0 = CFNew(0, yOffsetWaist / 1.4, 0) * CFAng(0, -asin(cameraDirection.x) / 1.4, 0) * CFAng(asin(cameraDirection.y) / 1.4, 0, 0)
end
end
end)
StarterCharacterScripts
while task.wait() do
local camera = workspace.CurrentCamera.CFrame
local character = game.Players.LocalPlayer.Character
local RS = game:GetService("ReplicatedStorage")
RS:FindFirstChild("HandleCameraProperties"):FireServer(camera, character)
end
The issue you’re experiencing with the torso position being offset when the camera is moved through events on the server is likely due to the way you’re handling the camera and character positions. When you move the camera on the server using events, you’re essentially changing the character’s position relative to the camera, but you’re not updating the character’s local position in the same way that the client would when the camera is moved.
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local Workspace = game:GetService("Workspace")
local function updateCamera()
local player = Players.LocalPlayer
local character = player.Character
local root = character:WaitForChild("HumanoidRootPart")
local neck = character:FindFirstChild("Neck", true)
local waist = character:FindFirstChild("Waist", true)
local CFNew, CFAng, asin = CFrame.new, CFrame.Angles, math.asin
local cameraDirection = root.CFrame:toObjectSpace(Workspace.CurrentCamera.CFrame).lookVector
if neck then
neck.C0 = CFNew(0, 0, 0) * CFAng(0, 0, 0)
end
if waist then
waist.C0 = CFNew(0, 0, 0) * CFAng(0, 0, 0)
end
local yOffsetNeck = 0
local yOffsetWaist = 0
local cameraCFrame = Workspace.CurrentCamera.CFrame
root.CFrame = CFNew(neck.C0.Position)
local cameraPosition = cameraCFrame * Vector3.new(0, 5, 0)
local rootPosition = root.Position + (cameraPosition - root.CFrame.Position)
root.CFrame = CFNew(rootPosition)
if neck then
neck.C0 = CFNew(0, 0, 0) * CFAng(0, -asin(cameraDirection.x), 0) * CFAng(asin(cameraDirection.y), 0, 0)
end
if waist then
waist.C0 = CFNew(0, 0, 0) * CFAng(0, -asin(cameraDirection.x), 0) * CFAng(asin(cameraDirection.y), 0, 0)
end
end
RunService.RenderStepped:Connect(updateCamera)
I’m really not a very good programmer, but I tried to help in some way. In general, if you want to make movement and camera view like in the game Doors, then first of all use the Realism module.