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

How do I make a sound play when a gun on a plane shoots?

Asked by 3 years ago

So i made a plane using a kit, when a gun shoots it doesn't make a sound. So when you enter the plane there's a tool that opens up the HUD, there's a local script and i found with a function that makes the gun fire, so i need help cause i dunno what to type in and where: (also i already put the sound in the tool)

``function FireMachineGun(GunParent)

--This function creates the bullets for the MachineGuns

while FiringGun do

    for _,v in pairs(GunParent:GetChildren()) do --This is what allow you to put as many MachineGuns as you want in the Guns folder

        if v:IsA("BasePart") then

            if v.Name == "MachineGun" then

                local Part = Instance.new("Part")

                Part.BrickColor = BrickColor.new("Bright yellow")

                Part.Name = "Bullet"

                Part.CanCollide = false

                Part.FormFactor = "Symmetric"

                Part.Size = Vector3.new(5,5,3)

                Part.BottomSurface = "Smooth"

                Part.TopSurface = "Smooth"

                local Mesh = Instance.new("BlockMesh")

                Mesh.Parent = Part

                Mesh.Scale = Vector3.new(1/12.5,1/12.5,1)

                local BV = Instance.new("BodyVelocity")

                BV.Parent = Part

                BV.maxForce = HugeVector

                local PlaneTag = Instance.new("ObjectValue")

                PlaneTag.Parent = Part

                PlaneTag.Name = "PlaneTag"

                PlaneTag.Value = Plane

                Part.Touched:connect(function(Object) --This lets me call the "Touched" function, which means I don't need an external script

                    if IsIgnored(Object) then return end

                    if (not Object:IsDescendantOf(Character)) then

                        local HitHumanoid = Object.Parent:findFirstChild("Humanoid")

                        if HitHumanoid then

                            HitHumanoid:TakeDamage(100) --This only damges the player if they don't have a forcefield

                            local CreatorTag = Instance.new("ObjectValue")

                            CreatorTag.Name = "creator"

                            CreatorTag.Value = Player

                            CreatorTag.Parent = HitHumanoid

                            delay(0.1,function() CreatorTag:Destroy() end)

                        elseif (not HitHumanoid) then

                            Object:BreakJoints()

                        end

                        CreateShockwave(Part.Position,5)

                    end
                end)
                Part.Parent = game.Workspace
                Part.CFrame = v.CFrame + v.CFrame.lookVector * 10
                BV.velocity = (v.Velocity) + (Part.CFrame.lookVector * 2e3) + (Vector3.new(0,0.15,0))
                delay(2,function() Part:Destroy() end)
                table.insert(IgnoreTable,Part)
            end
        end
    end
    wait(GunTime2)
end

end``

0
Oof. lunar_maker 2 — 3y
0
put it after u want it to fire? kkfilms_1 68 — 3y

Answer this question