Throwing object is not working

I’m trying to make it so when you activate a tool an object is thrown. For this, I am using body velocity. However, the function to actually throw the object is not being called. I tried to use tool.Activated, but to no avail.

Screenshot:

Any help will be appreciated :cowboy_hat_face:

1 Like

Just for a test, could you add a print statement the line after declaring the function?

local function on_equip()
    print("test")
    if not db then

make sure that the manualactivationonly property is disabled on the tool.
if it’s disabled, try activating the tool manually using tool:Activate() to see if it is an error in your code or not

tool.Activated:Connect(function()
on_equip()
end)

Don’t use deprecated Instances in your work. Let that be a heads-up, by the way.


If you’re trying to make a Tool that can be thrown by click, it’s much more easier than you think. You can just create a tool with no handle, (Make sure to set the RequiresHandle property to false.), and put a little script inside that looks something like this:

local DS = game:GetService("Debris")

local tool = script.Parent

local throwSpeed = 100

tool.Activated:Connect(function()
    
    local player = game.Players:FindFirstChild(tool.Parent.Parent.Name) or game.Players:GetPlayerFromCharacter(tool.Parent)
    
    local part = Instance.new("Part", workspace)
    part.Size = Vector3.new(1,1,1)
    part.Shape = Enum.PartType.Ball
    part.Position = player.Character.HumanoidRootPart.CFrame + (player.Character.HumanoidRootPart.CFrame.LookVector*3)
    part.AssemblyLinearVelocity = player.Character.HumanoidRootPart.CFrame.LookVector * throwSpeed
    DS:AddItem(part,5)
    
end)

Might look a bit messy, but just try it. It might work.

Thank you so much! I didn’t realize it was disabled! :cowboy_hat_face:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.