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

My rapid fire gun won't work, why?

Asked by 10 years ago
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

Log in to vote
0
Answered by
hudzell 238 Moderation Voter
10 years ago
if mouse ~= nil then

Try that

Ad

Answer this question