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

Help with creating bullets?

Asked by 10 years ago

Instead of using raycast, I'd like to create a bullet that moves through the air as it is shot, instead of being directly hit like a raycast. Where do I start?

1 answer

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
10 years ago

For this then you could either use BodyThrust, or BodyPosition with the Bullet part. The latter is preferred. When you 'fire' the gun then you can create a part, set it's CFrame relative to the handle and then put BodyPosition in it, with the 'position' property set to the Mouse's hit position.

Example;

local plr = game.Players.LocalPlayer
local mouse =  plr:GetMouse()

mouse.Button1Down:connect(function()
    local pos = mouse.Hit.p
    --Part Creation--
    local b = Instance.new("BodyPosition", CreatedPart)
    b.position = pos
end)
Ad

Answer this question