I have some code that will clone a tool from Server storage to the player’s backpack. The problem is once the remote event is fired, the tool isn’t in the backpack. The cloned tool just disappeared, with no errors, nothing.
game.ReplicatedStorage.GiveTool.OnServerEvent:Connect(function(player)
local toolToGive = game.ServerStorage.Tool
local toolClone = toolToGive:Clone()
toolClone.Parent = game.Players[player.Name].Backpack
end)
I see some posts saying I should add (see below) but I wanted to fire it based on a remote event.
You should only add the second portion if you think that the player might be dead when they are receiving the tool.
Your code looks fine, except for the what was mentioned in the first reply about changing game.Players[player.Name].Backpack to just player.Backpack, as OnServerEvent takes in a player object.
I think your issue is that your remote event is not being fired. You might want to do a test to make sure it is, and that it goes through the code without any errors.
script.Parent.ClickDetector.MouseClick:Connect(function(player)
if player then
local tool = game.ReplicatedStorage.ToolName:Clone()
tool.Parent = player.Backpack
script.Parent:Destroy()
end
end)