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

Gun script not working ?

Asked by 8 years ago

The bullet just doesn't go the direction the players mouse is but it just spawns the bullet.

Player = game.Players.LocalPlayer
Gun = script.Parent
Ammo = 5
mouse = Player:GetMouse()
function Shot(test)
    if Ammo > 0 then
        Bullet = Instance.new("Part", Workspace)
        game.Debris:AddItem(Bullet, 2)
        Bullet.Shape = "Ball"
        Bullet.Size = Vector3.new(0.1, 0.1, 0.1)
        Bullet.TopSurface = "Smooth"
        Bullet.BottomSurface = "Smooth"
        Bullet.BrickColor = BrickColor.new("Lime green")
        Bullet.CanCollide = false
        Bullet.CFrame = Gun.Handle.Cframe
        Bullet.CFrame = CFrame.new(Bullet.Position,mouse.Hit.p)
        BM = Instance.new("SpecialMesh", Bullet)
        BM.MeshType = "Sphere"
        BM.Scale = Vector3.new(0.2, 0.2, 0.2)
        v = Instance.new("BodyVelocity", Bullet)
        v.velocity =  Bullet.CFrame.lookVector *90
        v.maxForce = Vector3.new(math.huge, math.huge, math.huge)
        FireSound = Instance.new("Sound", Bullet)
        FireSound.SoundId = "http://www.roblox.com/asset/?id=161875506"
        RP = math.random(60,80)
        RP = RP /10
        FireSound.Pitch = RP
        RV = math.random(70, 90)
        RV = RV /10
        FireSound.Volume = RV
        FireSound:Play()
        game.Debris:AddItem(FireSound, 2)


    end
end

Gun.Activated:connect(Shot)

2 answers

Log in to vote
0
Answered by
saenae 318 Moderation Voter
8 years ago

It looks to me as if your bullet might still be anchored.

0
This isn't an answer. If you just have a vague idea what an answer might be, comment, dont make an entire answer which clutters the question board. drew1017 330 — 8y
Ad
Log in to vote
0
Answered by
cuff5 10
8 years ago
Player = game.Players.LocalPlayer
Gun = script.Parent
Ammo = 5
mouse = Player:GetMouse()
function Shot(test)
    if Ammo > 0 then
        Bullet = Instance.new("Part", Workspace)
        game.Debris:AddItem(Bullet, 2)
        Bullet.Shape = "Ball"
        Bullet.Size = Vector3.new(0.1, 0.1, 0.1)
        Bullet.TopSurface = "Smooth"
        Bullet.BottomSurface = "Smooth"
        Bullet.BrickColor = BrickColor.new("Lime green")
        Bullet.CanCollide = false
    Bullet.Anchored = false --You did not add this.
        Bullet.CFrame = Gun.Handle.Cframe
        Bullet.CFrame = CFrame.new(Bullet.Position,mouse.Hit.p)
        BM = Instance.new("SpecialMesh", Bullet)
        BM.MeshType = "Sphere"
        BM.Scale = Vector3.new(0.2, 0.2, 0.2)
        v = Instance.new("BodyVelocity", Bullet)
        v.velocity =  Bullet.CFrame.lookVector *90
        v.maxForce = Vector3.new(math.huge, math.huge, math.huge)
        FireSound = Instance.new("Sound", Bullet)
        FireSound.SoundId = "http://www.roblox.com/asset/?id=161875506"
        RP = math.random(60,80)
        RP = RP /10
        FireSound.Pitch = RP
        RV = math.random(70, 90)
        RV = RV /10
        FireSound.Volume = RV
        FireSound:Play()
        game.Debris:AddItem(FireSound, 2)


    end
end

Gun.Activated:connect(Shot)


Answer this question