How would I make a throwable bomb?

I have a bomb mesh, but I’m just not sure how I’m supposed to make a throwable bomb that has a specific amount of time to blow up. How would I go about making this?

4 Likes

Well were gonna need to take input from the player, then once that input is finished we add some sort of bodymover to the ball in the forward direction and a little bit in the up direction, then right as its thrown after however many seconds, the bomb will blow up and be destroyed

1 Like

Do you have any previous scripting experiences like tool input and forces/velocities? Just curious.

1 Like

I have a tiny bit of experience on velocity’s, not sure how to manipulate the player’s mouse. I do have experience with tool input though.

1 Like

Oh Yeah, Here’s what I currently have, just not sure where to go after this…

local ActivationEvent = script.Parent:WaitForChild("ThrowBomb")
local BombFuse = script.Parent:WaitForChild("Bomb Fuse")
local Explosion = script.Parent:WaitForChild("Explosion")

ActivationEvent.OnServerEvent:Connect(function(player)
	local Bomb = script.Parent:WaitForChild("Handle"):Clone()
	Bomb.Parent = workspace:WaitForChild("ClonedBombs")
	
end)
local ActivationEvent = script.Parent:WaitForChild("ThrowBomb")
local tool = script.Parent
local player = game:GetService("Players"):GetPlayerFromCharacter(tool.Parent)

tool.Activated:Connect(function()
	ActivationEvent:FireServer(player)
end)
2 Likes

I’m not too experienced with mouses but what you can do is get the players mouse position by doing:

ActivationEvent:FireServer(player,player:GetMouse().Hit)

This sends the location of the mouse (make sure to change your OnServerEvent script).
Let me know if you need help with the velocities

1 Like

Ok, now that we have the player’s mouse position, how would I use the position of the tool and make a bomb curve forward and head to the mouse position?

1 Like

Forgot to mention you need to send the character as well to the event, whoops

ActivationEvent:FireServer(player,player:GetMouse().Hit,player.Character)

So it should look something like this:

ActivationEvent.OnServerEvent:Connect(function(player,mouse,char)
	local Bomb = script.Parent:WaitForChild("Handle"):Clone()
	Bomb.Parent = workspace:WaitForChild("ClonedBombs")
	
end)

Next you need to define the bomb’s position so do this:

Bomb.Position = char.HumanoidRootPart.CFrame.LookVector * 5 --the bigger the number the more further it is

This is as much as i’ll help with, solutions can vary from here and we’re not allowed to design entire script systems. If you’re still confused you can check out this documentation here: LinearVelocity | Roblox Creator Documentation.
All you need to do for linear velocities are giving your object of choice an attachment and setting it’s velocity and maxforce. Make sure to quickly delete it afterwards.

1 Like

If were doing

Bomb.Position = char.HumanoidRootPart.CFrame.LookVector * 5

Why get the mouse’s position?

1 Like

You need it for the velocity, Unless you’re trying to make the bomb go towards the humanoid root part’s angle you need it so it goes towards the mouse instead. probably should’ve mentioned what it did though, whoops.

1 Like

But you never use it?

You just set the Bomb’s position to the lookvector of the humanoid root part?

1 Like

I’m not saying you do that, I’m saying you need the mouse’s position to make the bomb go towards there.

1 Like