Hey! I’ve seen in a lot of games how, when you press backspace (if CanBeDropped is true), the tool equipped is dropped a couple studs in front of the player. In my case, the tool is dropped right in the character’s hand, so the player almost instanly picks it up again. Does anyone know how can I change this or at least set a debounce?
I believe you can work around this by setting Can touch on the handle to false the moment the tool is parented to workspace and then turning it on again, as tools use the Touch system.
I think the best way to fix the issue you’re facing is to disable the tool’s “CanBeDropped” property and to script your own dropping behavior instead, the following worked well for me.
local run = game:GetService("RunService")
local userInput = game:GetService("UserInputService")
local players = game:GetService("Players")
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local hrp = character:WaitForChild("HumanoidRootPart")
local tool = script.Parent
local handle = tool:WaitForChild("Handle")
tool.Equipped:Connect(function()
equipped = true
end)
tool.Unequipped:Connect(function()
equipped = false
end)
userInput.InputBegan:Connect(function(input, processed)
if processed then return end
if not equipped then return end
if input.KeyCode == Enum.KeyCode.F then
humanoid:UnequipTools()
handle.CFrame = hrp.CFrame * CFrame.new(0, handle.Size.Y, -12)
tool.Parent = workspace
local touchConnection do
touchConnection = handle.Touched:Connect(function(hitPart)
run.Stepped:Wait()
local hitModel = hitPart:FindFirstAncestorOfClass("Model")
if hitModel then
local hitPlayer = players:GetPlayerFromCharacter(hitModel)
if hitPlayer then
local hitHuman = hitModel:FindFirstChildOfClass("Humanoid")
if hitHuman then
if hitHuman.Health > 0 then
tool.Parent = hitPlayer.Backpack
touchConnection:Disconnect()
end
end
end
end
end)
end
end
end)
It doesn’t work for me, works exactly like backspace (gets instantly picked up). Also, I don’t think you can change stuff like CFrame or Parenting from a local script.
Do you know if any “.Dropped” event or something like that actually exists? If so, I can just make a server script using that event and… tool.CanTouch = false; wait(2); tool.CanTouch = true
I looked around the script and figured out these 2 lines were on the wrong place (because you shouldn’t change the tool handle’s CFrame when is still being parented by a character). I turned them and everything working just fine.
Of course, like I said before, this only works for client, so I’ll do the server part.
The order of those lines shouldn’t matter (unless there’s an extreme amount of lag present in your game). Yes, you’ll need to make use of a RemoteEvent if you want the dropped tool to appear for every player. I wasn’t sure if you wanted a client-only implementation (so that only players can drop/pickup their own tools) or a server one.
I implore you to view the .gif I provided above, the order doesn’t matter (as the video demonstrates).
On a side note, you may run into issues if you attempt to bind the action to the backspace key as even when “CanBeDropped” is disabled Roblox has its own custom behavior for when the backspace key is pressed while a tool is equipped.
Converting into a server approach is a relatively simple change.
--CLIENT
local run = game:GetService("RunService")
local userInput = game:GetService("UserInputService")
local players = game:GetService("Players")
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local hrp = character:WaitForChild("HumanoidRootPart")
local tool = script.Parent
local remote = tool:WaitForChild("RemoteEvent")
tool.Equipped:Connect(function()
equipped = true
end)
tool.Unequipped:Connect(function()
equipped = false
end)
userInput.InputBegan:Connect(function(input, processed)
if processed then return end
if not equipped then return end
if input.KeyCode == Enum.KeyCode.F then
remote:FireServer()
end
end)
--SERVER
local players = game:GetService("Players")
local tool = script.Parent
local handle = tool.Handle
local remote = tool.RemoteEvent
remote.OnServerEvent:Connect(function(player)
local character = player.Character
local humanoid = character.Humanoid
local hrp = character.HumanoidRootPart
humanoid:UnequipTools()
handle.CFrame = hrp.CFrame * CFrame.new(0, handle.Size.Y, -12)
tool.Parent = workspace
local touchConnection do
touchConnection = handle.Touched:Connect(function(hitPart)
run.Stepped:Wait()
local hitModel = hitPart:FindFirstAncestorOfClass("Model")
if hitModel then
local hitPlayer = players:GetPlayerFromCharacter(hitModel)
if hitPlayer then
local hitHuman = hitModel:FindFirstChildOfClass("Humanoid")
if hitHuman then
if hitHuman.Health > 0 then
tool.Parent = hitPlayer.Backpack
touchConnection:Disconnect()
end
end
end
end
end)
end
end)
Hey, sorry for keep replying but, I’ve found something when your script is enabled: if I press the backspace key button (while moving) the player weirdly dies (the whole character turns to white color and “faints”), even though I assigned the script to the H key. I’m sorry for keeping the thread alive!
Yes, but if I’m walking (it only happens sometimes) and press backspace, my player dies in a weird way. Nevermind, it is probably a weird issue of mine.