How To Make A Throwable Tool

I was looking over the DevForum, and I couldn’t find how to make a throwable tool with a little curve in the air. How would I achieve this?

2 Likes

You could try getting the players mouse and then throwing an object with Linear Velocity that goes up, then destroy it after 1 second or more depending on how fast it’s going, then this can create a curve, I think

Also when the object touches the ground it should be deleted. Can you give an example how to achieve this?

You can insert a script into the part that detects what it touched is anchored, so that when it touches an anchored part, it will delete

If you’re just looking to literally unequip a tool from your inventory, just like how you do it by pressing backspace, then… just let the player press backspace and remove it, with the CanBeDropped property being set to true.


Jokes aside, I think I know what you want. You want an actual force to bring the tool forwards, to actually throw it. I can help you with that.

What we can really do is just parent the tool to workspace, then use the AssemblyLinearVelocity property to throw the tool forwards, to be picked up again.


Parent this script inside the tool:

local tool = script.Parent
local handle = tool.Handle

local throwSpeed = 50

tool.Activated:Connect(function()
    
    local player = game.Players:FindFirstChild(tool.Parent.Parent.Name) or game.Players:GetPlayerFromCharacter(tool.Parent)
    
    local cframe = handle.CFrame
    
    tool.Parent = workspace
    task.wait()
    handle.CFrame = CFrame.new(cframe.Position,player.Character.HumanoidRootPart.Orientation)
    
    handle.AssemblyLinearVelocity = handle.CFrame.LookVector * throwSpeed
    
end)

I also noticed how you mentioned “with a little curve” in your forum description. Unfortunately, I’m not entirely sure how you would go about doing that, but I’m pretty sure you can just add the force’s Y axis by 20 or something, and that should go up an angle.

This is how you could probably do it:

local throwSpeed = 50
local angleSpeed = 50 --The angle
handle.AssemblyLinearVelocity = (handle.CFrame.LookVector * throwSpeed) + Vector3.new(0,angleSpeed,0)

Mess with the values and see if the upwards angle and speed changes. Good luck on your project!

2 Likes

If you want it to happen when it touches specific items then you could put them in a folder, and if it hits something use a for loop to see if it was in the folder, and then destroy the tool.

Or you could do what the other guy said, which is checking if it was anchored.

script.Parent.Touched:Connect(function(hit)
if hit.anchored == true or hit.Parent.anchored == true then
script.Parent:Destroy()
 end
end)

Sorry if theres errors I wrote it in a rush.

Shouldn’t I use ApplyImpulse, since I just want it to throw once. If so, how can I do this?

Did you even try the script I recommended to you?

Yes, but it didn’t work at all. No errors, nothing happened.

Put a print() after the tool.Activated event, see if it actually fires.

It did fire, I have actually kind of found the cause. When the tool is parented to the workspace I immediately pick it up. So I basically only made the handle part of the workspace but the velocity just bring the tool through the map. Also with this velocity it keeps going down. Do you know how to use ApplyImpulse, because that looks like a better option to me. Right?