When a character has a tool equipped, it is in their character in workspace.
When they don’t, it is in Players>Player>Backpack.
You could try checking:
if character:FindFirstChildWhichIsA("Tool") then
-- either move the tool that is equipped to the backpack or move that tool that is trying to be equipped to the backpack
end
or
if not character:FindFirstChildWhichIsA("Tool") then
local FruitTool = game.ServerStorage.Tool:Clone()
FruitTool.Parent = character
else
local FruitTool = game.ServerStorage.Tool:Clone()
FruitTool.Parent = player.Backpack -- assuming you have a player variable somewhere, if not, use PlayerService:GetPlayerFromCharacter(character)
end
Anyone correct me if I’m wrong, as I’m not the best when messing with Player stuff
The “glitch” happens because you’re setting the parent of the tool directly into the character, without checking if there is already a tool. It might be confusing because when a tool is on the ground and has a Handle (so it can be picked up), when a character does pick it up, Roblox automatically detects and unequips any other tools. The same does not happen when you set the parent of a tool to the character.
Yeah, it’s confusing, but you always gotta know that your scripts are your problem, and Roblox only checks stuff with their own services.
Also; some more things I noted is that you’re storing the tool directly in ServerStorage. Maybe try creating a folder to separate individual tools, for organization. And use a variable to store ServerStorage as it is used more than once
e.g:
local ServerStorage = game:GetService("ServerStorage") -- always use :GetService() instead of dot, don't ask me why, it's just better and more common
local fruitTools = ServerStorage.Tools.Fruits
if not character:FindFirstChildWhichIsA("Tool") then
local FruitTool = fruitTools.Tool:Clone()
FruitTool.Parent = character
else
local FruitTool = fruitTools.Tool:Clone()
FruitTool.Parent = player.Backpack -- assuming you have a player variable somewhere, if not, use PlayerService:GetPlayerFromCharacter(character)
end