Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

Help with making a FPS gun?

Asked by 9 years ago

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

0
I do not know how to do this, but I would like to know. You really should tab your code correctly, however. Perci1 4988 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

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

Ad

Answer this question