Just realized you meant to parent it to ReplicatedStorage (I would still recommend using ServerStorage). But still no problem.
Make sure to put a RemoteEvent in ReplicatedStorage. you can name it if you want but you need to match the new name with the scripts too
ServerScriptService script
remoteEvent.OnServerEvent:Connect(function(player)
local backpack = player:FindFirstChild("Backpack")
if backpack then
local AK = backpack:FindFirstChild("AK101")
if AK then
AK.Parent = game.ServerStorage
end
end
end)
Local Script
local remoteEvent = game.ReplicatedStorage.RemoteEvent
script.Parent.MouseButton1Click:Connect(function()
remoteEvent:FireServer() -- Fire the remote event to the server
end)
If your problem still doesn’t get solved though I’ll try to replicate it later once I’m back on my PC. It’s kind of hard trying to make scripts if I can’t test it directly
Are you firing the remote event with the tool equipped? If yes, you should know that every tool equipped by the player is placed at his character in workspace, not in Backpack, so:
local AK = backpack:FindFirstChild("AK101")
if AK then -- false if the tool is equipped, so the condition is skipped.
AK.Parent = game.ServerStorage
end
Maybe you could do a check for searching the tool in player’s character too?