I have been making third person gun system and it looks unrealistic when
you shoot down or up because the hands are in a fixed position.
I wanted to make the waist and head look at the position of the mouse
and I found out how but I would like to make it only active when the
tool is equipped.
Server Script:
wait(1)
game.ReplicatedStorage.Look.OnServerEvent:Connect(function(player, neckCFrame)
for key, value in pairs(game.Players:GetChildren()) do
if value ~= player and (value.Character.Head.Position - player.Character.Head.Position).Magnitude < 10000 then
game.ReplicatedStorage.Look:FireClient(value, player, neckCFrame)
end
end
end)
Local Script:
wait(5)
local cam = workspace.CurrentCamera
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hrp = char:WaitForChild("HumanoidRootPart")
if char.Humanoid.RigType == Enum.HumanoidRigType.R6 or char.Humanoid.Died then
script.Disabled = true --Sorry this script not for R6
end
local Neck = char:FindFirstChild("Neck", true)
local Waist = char:FindFirstChild("Waist", true)
local tweenService = game:GetService("TweenService")
local y = Neck.C0.Y
local yt = Waist.C0.Y
local mouse = plr:GetMouse()
local RE = game.ReplicatedStorage
wait(3)
game:GetService("RunService").RenderStepped:Connect(function()
local mouse = plr:GetMouse()
local camDirection = hrp.CFrame:ToObjectSpace(mouse.Hit).LookVector
if Neck then
Neck.C0 = Neck.C0:Lerp(CFrame.new(0, y, 0) * CFrame.Angles(0, -camDirection.X/1.5, 0) * CFrame.Angles(camDirection.Y/1.6, 0, 0),0.1)
Waist.C0 = Waist.C0:Lerp(CFrame.new(0, yt, 0) * CFrame.Angles(0, -camDirection.X/1.5, 0) * CFrame.Angles(camDirection.Y/1.6, 0, 0),0.1)
end
end)
RE.Look.OnClientEvent:Connect(function(otherPlayer, neckCFrame)
local Neck = otherPlayer.Character:FindFirstChild("Neck", true)
if Neck then
tweenService:Create(Neck, TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0), {C0 = neckCFrame + Vector3.new(0,0,0)}):Play()
end
end)
RE.Look.OnClientEvent:Connect(function(otherplr, WaistCFrame)
local Waist = otherplr.Character:FindFirstChild("Waist", true)
if Waist then
tweenService:Create(Waist, TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0), {C0 = WaistCFrame - Vector3.new(0, 0.6, 0)}):Play()
end
end)
local m
m = mouse.Hit
while wait(1) do
if m ~= mouse.Hit then
RE.Look:FireServer(Neck.C0)
m = mouse.Hit
end
end
If you know how to do it, please tell me.
Have a great day.