In my code, at the if statement on line 21, it SHOULD be detecting when the mouse is clicked. But in my console, it is not printing "Player has thrown a knife." Even when i told it to when the tool is used. Everything EXCEPT this if statement works. But the weird thing is, i am not getting any errors.
ReplicatedStorage.GiveKnife.OnServerEvent:Connect(function(player)
local humanoid = player.Character:FindFirstChildOfClass("Humanoid")
if humanoid then
humanoid:UnequipTools()
print("Knife deselected.")
end
if player.Backpack:FindFirstChild("Knife") then
player.Backpack.Knife:Destroy()
print("Knife destroyed")
end
myKnife = game.ServerStorage.Knife:Clone()
myKnife.Parent = player.Backpack
myKnife.Name = "Knife"
print("Knife created")
myKnife.Equipped:Connect(function(mouse)
mouse.MouseButton1Click:Connect(function(player)
print(player.."has thrown a knife.")
end)
end)
end)

2 comments
Maybe try myKnife.Activated?
MouseButton1Click is an RBXScriptSignal of GUIButton. You're looking for Button1Down.