Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make a Moving Projectile?

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

✓ Accepted answer

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.

2 comments

0

Thank you, but how would I apply a body force to my grenade?

0

Updated answer ^^

This discussion is preserved as it was. New answers, comments, and votes are closed.