So I have tried to make a script where the arms point towards the mouse, but I am trying to make it serversided.
But whenever I make it serversided its super laggy and unusable.
Heres the LocalScript
local player = game.Players.LocalPlayer
local character = player.Character
if not character or not character.Parent then
character = player.CharacterAdded:wait()
end
local humanoid = character:WaitForChild("Humanoid")
local torso = character:WaitForChild("Torso")
local rightShoulder = torso:WaitForChild("Right Shoulder")
local leftShoulder = torso:WaitForChild("Left Shoulder")
local camera = game.Workspace.CurrentCamera
updateSpeed = 0.5/2
game:GetService("RunService").RenderStepped:Connect(function()
local camCF = camera.CoordinateFrame
script.camCF.Value = camCF
--[[
local camCF = camera.CoordinateFrame
local distance = (character.Head.Position - camCF.p).magnitude
if humanoid.Health ~= 0 then
rightShoulder.C0 = rightShoulder.C0:lerp((camCF * CFrame.new(1, -1, 0)):toObjectSpace(torso.CFrame):inverse() * CFrame.Angles(0, math.pi/2, 0), updateSpeed)
leftShoulder.C0 = leftShoulder.C0:lerp((camCF * CFrame.new(-1, -1, 0)):toObjectSpace(torso.CFrame):inverse() * CFrame.Angles(0, -math.pi/2, 0), updateSpeed)
end
--]]
script.CamData:FireServer(camCF)
end)
And here is the ServerScript nested inside of said LocalScript
local player = script.Parent.Parent.Parent
local character = player.Character
if not character or not character.Parent then
character = player.CharacterAdded:wait()
end
updateSpeed = 0.5/2
local humanoid = character:WaitForChild("Humanoid")
local torso = character:WaitForChild("Torso")
local rightShoulder = torso:WaitForChild("Right Shoulder")
local leftShoulder = torso:WaitForChild("Left Shoulder")
game:GetService("RunService").Stepped:Connect(function()
if humanoid.Health ~= 0 then
rightShoulder.C0 = rightShoulder.C0:lerp((script.Parent.camCF.Value * CFrame.new(1, -1, 0)):toObjectSpace(torso.CFrame):inverse() * CFrame.Angles(0, math.pi/2, 0), 0.5/2)
leftShoulder.C0 = leftShoulder.C0:lerp((script.Parent.camCF.Value * CFrame.new(-1, -1, 0)):toObjectSpace(torso.CFrame):inverse() * CFrame.Angles(0, -math.pi/2, 0), 0.5/2)
end
end)
script.Parent.CamData.OnServerEvent:Connect(function(p, data)
script.Parent.camCF.Value = data
end)
And This is all inside of StarterGUI btw
I am trying to make it look like this btw
But just not laggy when you enter firstperson and just laggy in general