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?
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)
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.
Then this script should work with what you want.
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.