Tools drop too close!

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?

Thank you for reading!

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.

1 Like

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)

https://gyazo.com/5e0259d4b389044638658d9fa9376997

Here’s the model file if you’d like to take a further look:
tool.rbxm (3.9 KB)

2 Likes

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.

Thank you for replying!

I attached a gif which demonstrates that it works, you may need to fiddle with this bit here.

CFrame.new(0, handle.Size.Y, -12)
1 Like

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

Thank you for replying!

Local scripts can be used to modify the CFrame property of a tool’s handle, I’m not sure who told you otherwise.

Remember that the client has network ownership over their character (not the server).

It might be helpful if you provided the tool (model) you’re working with.

https://developer.roblox.com/en-us/api-reference/class/Tool

Tool instances do not have a “.Dropped” event, all of their available events can be found in the link above.

1 Like

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.

image

Of course, like I said before, this only works for client, so I’ll do the server part.

Thank you for helping me!

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.

1 Like

The order of the lines is a very important thing! I really don’t know how you were running the code on that order!

Of course I’d want a server implementation, that’s what drop system is for (giving tools).

Thank you for helping me! I’ll think I’ll make my way to the server side.

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)

tool.rbxm (4.7 KB)

3 Likes

I was doing exactly this but, instead of using a server script on each tool, I’ll implement one in the server script service.

Thank you!

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!

Nothing is bound to the backspace key (only the “F” key) so there’s likely some other script causing those issues.

https://gyazo.com/25c18ead8744146ea36e9179f0d5a8ee

When pressing the backspace key the tool just unequips.

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.