How should I go about making a throwable object depending on the players mouse position?

I want to make a grenade, but Im not sure how to make it so that I can calculate the direction and power of the throw to make it go far or less far.

There are countless topics on this already that can definitely help you. :slight_smile:

For example:
How to make a grenade system?(help) - Help and Feedback / Scripting Support - DevForum | Roblox

Modeling a projectile’s motion - Resources / Community Tutorials - DevForum | Roblox

How to make grenade projectile more accurate to the mouse? - Help and Feedback / Scripting Support - DevForum | Roblox

2 Likes

Thanks for the links, but is there anything less complicated that I can do to make this system?

I don’t have a good grasp of calculous yet, and I don’t want to learn for months or wait until 11th or 12th grade just to learn it. Is that the only solution that would work well, or is there a possible alternative?

i would just use body movers (30char)

But how can I calculate and get a visible range from which the projectile will go, without having to use and rely on a strong amount of calculus?

This function, taken from Modeling a projectile’s motion - Resources / Community Tutorials - DevForum | Roblox gives you a very good starting point.

If you find something like this is out of your depth, then perhaps you should start on something easier and work your way from there. :slight_smile:

local t = 1;
local mouse = game.Players.LocalPlayer:GetMouse();
local hrp = game.Players.LocalPlayer.CharacterAdded:Wait():WaitForChild("HumanoidRootPart");
local bball = script.Parent:WaitForChild("Handle");

mouse.Button1Down:Connect(function()
	local g = Vector3.new(0, -game.Workspace.Gravity, 0);
	local x0 = hrp.CFrame * Vector3.new(0, 2, -2)
	
	-- calculate the v0 needed to reach mouse.Hit.p
	local v0 = (mouse.Hit.p - x0 - 0.5*g*t*t)/t;
	
	-- have the ball travel that path
	local c = bball:Clone();
	c.Velocity = v0;
	c.CFrame = CFrame.new(x0);
	c.CanCollide = true;
	c.Parent = game.Workspace;
end)
1 Like

That seems simpler, but Im not sure what all of these variables would stand for like t or g, but g may be gravity.