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

What is the problem with my gun firing script? (New problem found...)

Asked by 9 years ago

local damage = 50 local auto = true local mags = 8 tool = script.Parent handle = tool.Handle keys = {"q", "e"} local cam = workspace.CurrentCamera local barral = tool.Barrel local bullets = tool.rounds.Value function shots() repeat wait (0.2) local bullet = Instance.new("Part") bullet.Name = "Bullet" bullet.CFrame = CFrame.new(barral.CFrame) bullet.Velocity = Vector3.new(100, 0, 0) bullet.Size = Vector3.new(0.5, 0.5, 1.5) bullets = bullets -1 bullet.Touched:connect(function(hit) local ALIEN = hit.Parent.FindFirstChild("alien") alien:TakeDamage(damage) end) if bullets == 0 then mags = mags -1 wait (5) end until mags == 0 end function onKeyDown(key) if key == "q"then cam.CameraSubject = tool.looksight cam.CameraType = custom elseif key == "e" then game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid game.Workspace.CurrentCamera.CameraType = "Custom" end end tool.Activated:connect(shots)

so i got help on that, but now, the output says: 14:19:33.240 - Players.Player1.Backpack.turret.LocalScript:16: bad argument #1 to 'new' (Vector3 expected, got userdata) 14:19:33.244 - Script 'Players.Player1.Backpack.turret.LocalScript', Line 16 14:19:33.247 - Stack End

1 answer

Log in to vote
0
Answered by
Nymint 85
9 years ago
--Line 25
bullet.Hit:connect(function(hit) end) --(No.)
bullet.Touched:connect(function(hit) end) --(Yes.)
-- BUT. You have a problem here, you're using a local variable that is INSIDE a function called shots()
--If you make a local variable and try to call it outside of the area you just created it, it won't do the job. just move the .Touched event function inside shots()
--And, Line 26
Brick.FindFirstChild --(No.)
Brick:FindFirstChild --(Yes.)

You can just use "Workspace" now, instead of game.Workspace. I suggest you to learn about WaitForChild.

0
Thank you, i usually catch the functions, im just trying to think of to many things at once, becuase im trying to make a huge update to my game, my friends skyping me, so those to things distract me easily right now... thank you. rollercoaster57 65 — 9y
0
Actually, its supposed to be that only an alien humanoid in my game is affected aswell. rollercoaster57 65 — 9y
0
That helped... but i have a new problem now. rollercoaster57 65 — 9y
0
What is it? Nymint 85 — 9y
0
its up there... rollercoaster57 65 — 9y
Ad

Answer this question