Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Help with making a FPS gun?

So i've struggled for weeks on how to create a FPS gun, I know how to create the gun itself so that it can fire, reload and such but its the thing that makes the arms, head follow either my mouse or the camera.

An example:

plr = game.Players.LocalPlayer

char = plr.Character

torso = char:WaitForChild("Torso")

sh = {torso["Right Shoulder"], torso["Left Shoulder"]}

arms = {char["Right Arm"], char["Left Arm"]}

t = script.Parent

h = t.Handle

eq = false




t.Equipped:connect(function()
sh[1].Part1 = nil
local w = Instance.new("Weld", torso)
 w.Name = "RA_weld"
  w.Part0 = arms[1]
w.Part1 = torso
w.C0 = arms[1].CFrame:inversse()
w.C1 = torso.CFrame:inverse()
 eq = true
end)

while wait() do if eq then
local targ = (cam.CoordinateFrame*CFrame.new(0,0,-100)).p
w.C0 = CFrame.new(headpos.p,targ) -headpos.p


end end

1 comment

0

I do not know how to do this, but I would like to know. You really should tab your code correctly, however.

1 answer

If your gun has a weld, your arms will not follow the camera.

This discussion is preserved as it was. New answers, comments, and votes are closed.