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

How would I make a script to throw an object?

Asked by 6 years ago

I'm trying to make a grenade. I'm stuck on the throwing part. I don't understand how u would get the throw to happen smoothly please help me if u can.

1 answer

Log in to vote
0
Answered by 6 years ago

The grenade would need to be affected by it's velocity, lookVector, and magnitude.

Velocity for it's speed in a direction which I would assume to be the primary way of how a grenade is being thrown.

lookVector is the direction in a Vector3 value that the grenade would be facing. It would be a property of CFrame.

Magnitude to conclude the distance between A and B or grenade to target position.

If you want a grenade to throw towards the player's mouse, you would need mouse.Hit.p, the position of the mouse where it clicked.

You would most likely need a local script and server script communicating with a remote event since local scripts are the only scripts capable of accessing the player's mouse. It can send info to the remote server providing the function at the server script the mouse's clicked position.

If you want to make the best grenade possible, lots of math will be needed.

0
Ok thanks. rilgundam 65 — 6y
0
Please accept my answer if you found it helpful. User#18043 95 — 6y
Ad

Answer this question