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

Help with blocks and body velocity?

Asked by
Scootakip 299 Moderation Voter
8 years ago
game.Debris:AddItem(Bullet, 2)
        Bullet.Shape = "Ball"
        Bullet.Size = Vector3.new(2,0.1,0.1)
        Bullet.TopSurface = "Smooth"
        Bullet.BottomSurface = "Smooth"
        Bullet.Transparency = 0
        Bullet.BrickColor = BrickColor.new("Lime green")
        Bullet.CanCollide = false
        Bullet.CFrame = Gun.P4.CFrame
        Bullet.CFrame = CFrame.new(Bullet.Position,mouse.Hit.p)
        v = Instance.new("BodyVelocity", Bullet)
        v.velocity = Bullet.CFrame.lookVector *90
        v.maxForce = Vector3.new(math.huge, math.huge, math.huge)

This is part of my gun script, which uses BodyVelocity to have the bullet travel. The only problem is that it only work when it is a Ball shape. I need the bullet to be a Block shape for the 1 gun, but for whatever reason whenever I set the shape to Block it just freezes in mid-air. It's not anchored or anything. Help?

1 answer

Log in to vote
0
Answered by
theCJarmy7 1293 Moderation Voter
8 years ago

i used this:

script.Parent.Equipped:connect(function(mouse)
    mouse.Button1Down:connect(function()
local Gun = script.Parent.Handle
local Bullet = Instance.new("Part")
        Bullet.Shape = "Block"
        Bullet.Size = Vector3.new(2,0.1,0.1)
        Bullet.TopSurface = "Smooth"
        Bullet.BottomSurface = "Smooth"
        Bullet.Transparency = 0
        Bullet.BrickColor = BrickColor.new("Lime green")
        Bullet.CanCollide = false
        Bullet.CFrame = Gun.CFrame
Bullet.Anchored = false
Bullet.Parent = game.Workspace
        Bullet.CFrame = CFrame.new(Bullet.Position,mouse.Hit.p)
        local v = Instance.new("BodyVelocity", Bullet)
v.Parent = Bullet
        v.velocity = Bullet.CFrame.lookVector *90
        v.maxForce = Vector3.new(math.huge, math.huge, math.huge)
game:GetService("Debris"):AddItem(Bullet,2)
    end)
    end)

and it worked fine. i don't know why your gun would make the parts in mid air, but this worked fine for me.

Ad

Answer this question