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

How do I make a projectile bullet?

Asked by 5 years ago

Hello,

I'm trying to make a weapon and this is its LocalScript:

local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Mouse = Player:GetMouse()
if not Player.Character then repeat wait() until Player.Character end
local Character = Player.Character
local Humanoid = Character:WaitForChild("Humanoid")

local Glock = script.Parent
local Handle = Glock:WaitForChild("Handle")
local Muzzle = Glock:WaitForChild("Muzzle")

local OnActivated = function()
    local Bullet = Instance.new("Part", workspace)
    Bullet.Material = Enum.Material.Neon
    Bullet.CanCollide = false
    Bullet.Anchored = false
    Bullet.Locked = true
    Bullet.FormFactor = Enum.FormFactor.Custom
    Bullet.BrickColor = BrickColor.new("Bright yellow")
    Bullet.Size = Vector3.new(0.25, 0.25, 5)
    Bullet.Position = Handle.Position
    Bullet.CFrame = CFrame.new(Bullet.CFrame.p, Mouse.Hit.p)
    local BodyVelocity = Instance.new("BodyVelocity", Bullet)
    BodyVelocity.Velocity = Bullet.CFrame.lookVector * 120
end

Glock.Activated:Connect(OnActivated)

But I realised the bullet's velocity is really slow. When I tried to increase it, the bullet goes in a weird way.

Is there a way I can use it without making it look weird? Thanks.

0
Try to use Ray Casting. If you need help with that you can go here: https://developer.roblox.com/articles/Making-a-ray-casting-laser-gun-in-Roblox namespace25 594 — 5y
0
I'm actually trying to make a weapon that fires projectiles now, I've made ray-casting weapons multiple times. Hellnickell 5 — 5y
0
he never found his answer :( botw_legend 502 — 3y
0
i have this problem 2 botw_legend 502 — 3y
View all comments (2 more)
0
make the max velocity math.huge and make the number the bullet cframe lookvector is multuplied by bigger. zhenjie2003 0 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

Try this https://devforum.roblox.com/t/how-to-make-ranged-weapons-with-bullet-movement/606618/4

Ad

Answer this question