Help with making gun follow camera

So I’m trying to make it so a gun follows the camera. The gun is a tool in starterpack and the following script is parented to the handle. it is a local script.

local rs = game:GetService("RunService")
rs.RenderStepped:Connect(function()
	script.Parent.CFrame = workspace.Camera.CFrame	
end)

The problem is that it doesn’t achieve its intended effects and all the script does is fling the player. The reason it does this is because when the handles CFrame is set, the characters CFrame moves to it. Is there a way to fix this?

1 Like

Ensure that all parts of the gun has can collide set to false.

1 Like

They are all set to false. Thats not the problem

No idea if that works. Maybe give it a try:

local camera = workspace.CurrentCamera
local part = game.Players.Character:WaitForChild("Head")

local rs = game:GetService("RunService")
rs.RenderStepped:Connect(function()
script.Parent.CFrame = CFrame.new(Vector3.new(part.CFrame),Vector3.new(camera.CFrame))
end)

just tried to do that and it flung me too.

From what I can tell Roblox creates an invisible weld to make the character hold onto a tool, so if you move the handle you move the entire character.

A work around would be to have both a handle and the model of the gun, weld the gun to the handle, then make the Handle invisible.
layout
Then this script should work with what you want.

The issue is the humanoid. Try using an animation controller, or changing the collision groups of the parts of your viewmodel.

unfortunately that did not work either unless i did something wrong.

what do you mean by this. do i change anything in specific.

That’s weird, I think the weld might be off. It works here
robloxapp-20200713-1713404.wmv (1.1 MB)

Is Part0 the gun and Part1 the Handle?

yeah i tried again, i think the problem is the gun im using consists of multiple parts so I modeled it. I adjusted the parents accordingly within the scripts though and set the primary part too.