SCRIPT:
local player = game.Players.LocalPlayer local char = player.Character local cam = workspace.Camera local arms = game.ReplicatedFirst.Arms:Clone() local MyGun = script.Parent local GunHandle = MyGun:WaitForChild("Handle") arms.Parent = cam local Humanoid = arms.Humanoid local IdleAnimation = script.IdleAnim local ShootingAnimation = script.ShootAnim local ShootAnimTrack = Humanoid:LoadAnimation(ShootingAnimation) local IdleAnimTrack = Humanoid:LoadAnimation(IdleAnimation) IdleAnimTrack:Play() local mouse = player:GetMouse() mouse.Button1Down:Connect(function() ShootAnimTrack:Play() game.ReplicatedStorage.Shoot:FireServer(mouse.Hit.p) end) game:GetService("RunService").Stepped:Connect(function() for i = 1, 100 do arms:SetPrimaryPartCFrame(cam.CFrame * CFrame.new(0,-2,-2.5) * CFrame.Angles(0,0,0)) end end)
I am trying to make a gun script and it works, but the issue is that when you turn the camera, it looks clunky and it stutters. Is there any way I can make it more snappy?
Try using RenderStepped
instead of Stepped
.
game:GetService("RunService").RenderStepped:Connect(function() for i = 1, 100 do arms:SetPrimaryPartCFrame(cam.CFrame * CFrame.new(0,-2,-2.5) * CFrame.Angles(0,0,0)) end end)
I already found out this solution due to Gey4Jesus69. When using run service, use RenderStepped instead of Stepped, it's more reliable.