This gun script that is only supposed to have the gun face wherever my camera is keeps on moving me around really fast. The code is here:
local camera = game.Workspace.CurrentCamera
local humanoid = game.Players.LocalPlayer.CharacterAdded:Wait():WaitForChild("Humanoid")
local repWeapon = game.ReplicatedStorage:WaitForChild("P90")
local weapon = repWeapon:Clone()
local viewModel = game.ReplicatedStorage:WaitForChild("viewModel"):Clone()
weapon.Parent = viewModel
viewModel.Parent = camera
local joint = Instance.new("Motor6D")
joint.C0 = CFrame.new(1, -1.5, -2)
joint.Part0 = viewModel.Head
joint.Part1 = weapon.Handle
joint.Parent = viewModel.Head
local function onDeath()
viewModel.Parent = nil
end
local function onUpdate(dt)
viewModel.Head.CFrame = camera.CFrame
end
humanoid.Died:connect(onDeath)
game:GetService("RunService").RenderStepped:connect(onUpdate)

1 comment
Pretty sure it's camera.CoordinateFrame