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

Local Shoot is a nil value?

I'm making an automatic gun and it keeps saying that "Shoot" is a nil value

Here is my script.

if script.Parent.Parent.Parent.Name ~= "Backpack" then
local user = script.Parent.Parent.Parent
local hole = script.Parent.Parent.Hole

function Shoot(mouse)
	local firing = false
	if firing == false then
		firing = true
		local ray = Ray.new(hole.CFrame.p,(mouse.Hit.p - hole.CFrame.p).unit * 300)
			local hit, position = workspace:FindPartOnRay(ray, user)
			
			local human = hit.Parent:FindFirstChild('Humanoid')
			if human then
				human:TakeDamage(10)
			end
			local distance = (position - script.Parent.Parent.Handle.CFrame.p).magnitude
			local bullet = Instance.new("Part",user)
			bullet.BrickColor = BrickColor.new("Gold")
			bullet.Transparency = 0.5
			bullet.Material = Enum.Material.Neon
			bullet.CanCollide = false
			bullet.Anchored = true
			bullet.formFactor = Enum.FormFactor.Custom
			bullet.Size = Vector3.new(0.2,0.2,distance - 6)
			bullet.Name = "Bullet"
			bullet.CFrame = CFrame.new(position - script.Parent.Parent.Handle.CFrame.p) * CFrame.new(0,0,-distance / 2)
			game.Debris:AddItem(bullet,1/30)
			script.Parent.Parent.Ammo.Value = script.Parent.Parent.Ammo.Value - 1
			hole.Smoke.Enabled = true
			wait(.3)
			hole.Smoke.Enabled = false
			firing = false
		end
	end
end

local mousedown = false
script.Parent.Parent.Activated:Connect(function(Shoot)
	mousedown = true
	repeat
		wait(.1)
		Shoot()
	until mousedown == false
end)

1 answer

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