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

My rapid fire gun won't work, why?

plr=game.Players.LocalPlayer
mouse=plr:GetMouse()
local sp=script.Parent

local damage = 23

function shoot()
	local shot = Instance.new("Part")
	shot.Name"Bullet"
	shot.Anchored=true
	shot.CanCollide=true	
	shot.Parent=game.Workspace
	shot.Shape="Ball"
	shot.Size=Vector3.new(2, 2, 2)
	shot.TopSurface="Smooth"
	shot.BottomSurface="Smooth"
	
	sp.Touched:connect(function(hit)
		local hit = hit.Parent
		if plr:onTouched(bullet) then
			plr:findFirstChild(hit.Parent, "Humanoid")
			plr.Huamnoid.Health:TakeDamage(damage)
		else
			plr.findFirstChild("Head")
			if bullet:onTouched(Head) then
				plr.Huamnoid.Health=0
			end
		end
		end)
		sp.onClicked:connect(function(MouseButton1Click)
			if mouse then
				shoot()
				shoot()
				shoot()
				shoot()
			end
		end)
	end

I got stuck on if mouse then. Any help?

1 answer

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