I have this third person camera script in StarterGUI.
While seated moving the camera along the x axis also moves the part which the seat is welded to.
I’ve been thinking of simply locking the camera while the player is seated, but I’m sure there’s better options to preventing this. And is there any reason to why this is happening? This is only replicating to the client and not to the server.
https://gyazo.com/2d837ddcd45bf5e043539251723ff375
Camera Script
wait(0.1)
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local Client = game.Players.LocalPlayer
local Camera = workspace.CurrentCamera
local Char = Client.Character or Client.CharacterAdded:Wait()
local hrp = Char:WaitForChild("HumanoidRootPart")
local sens = 400
local x = 0
local y = 0
local FollowMouse = 0
local mouse = game.Players.LocalPlayer:GetMouse()
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter -- Set mouse icon
RunService:BindToRenderStep("Update", 100, function()
wait(0.1)
mouse.Icon = "http://www.roblox.com/asset?id=94643449"
UserInputService.MouseIconEnabled = true
end)
UserInputService.InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseMovement then
FollowMouse = 0
x = x + input.Delta.X/sens
y = math.clamp(y-(input.Delta.Y/sens), -1, 1)
end
end)
RunService:BindToRenderStep("CameraUpdate", Enum.RenderPriority.Camera.Value, function(dt)
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
local getCameraRot = CFrame.new(hrp.Position) * CFrame.Angles(0, -x, 0) * CFrame.Angles(y, 0, 0)
Camera.CFrame = getCameraRot * CFrame.new(0, 3, 6.5) -- Cam offset
hrp.CFrame = CFrame.new(hrp.CFrame.p) * CFrame.fromEulerAnglesXYZ(0, -x, 0)
FollowMouse = math.clamp(FollowMouse + dt, 0, 1)
end)