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

How to make a Moving Projectile?

Asked by 5 years ago

I’ve been making a grenade and I need it to to project. I’m not sure how I would do this but I think I need to use BodyMovers.

I don’t want raycasts but instead a “prefab” type of projectile.

Thanks for viewing this!

1 answer

Log in to vote
0
Answered by
Robin5D 186
5 years ago
Edited 5 years ago

Probably not bodymovers; something more like bodyforces or something that applies actual thrust to the grenade would suit you better and be more accurate. I don't know what you mean by 'prefab', but this is probably the way to go.

For example; if you wanted to throw the grenade where your mouse is pointed, your code would probably be something like this:

tool.Activated:Connect(function()
    local grenadeClone = fakeGrenade:Clone() -- fake grenade is probably the actual body of the grenade somewhere else like in replicatedstorage maybe (you could probably copy the handle of the tool)
    local bodyForce = Instance.new("BodyForce")
    grenadeClone:SetPrimaryPartCFrame(tool.Handle.CFrame)
    tool:Destroy()
    grenadeClone.Parent = workspace
    bodyForce.Force = playerHumanoid.TargetPoint.Unit * 100
    bodyForce.Parent = grenadeClone
end)

Remember: this is a rough draft; and probably won't work. Experiment.

0
Thank you, but how would I apply a body force to my grenade? 123nabilben123 499 — 5y
0
Updated answer ^^ Robin5D 186 — 5y
Ad

Answer this question