ServerScript not parenting tool into player Backpack

Hello, this is my first devforum post so correct me if im wrong on anything.

My issue is that my script in serverscriptservice is not parenting my tool from replicatedstorage into the player’s backpack upon a playeradded event and the print fires even without the tool being in the backpack.When parenting to workspace it works as intended.

I looked for similar posts on the devforum but could only find ones that parented tool to the backpack after a touched event.

The Script:

local Handgun = game.ReplicatedStorage.Handgun

game:GetService("Players").PlayerAdded:Connect(function(plr)
	local GunCopy = Handgun:Clone()
	GunCopy.Parent = plr:WaitForChild("Backpack")-- When i tried parenting to workspace it worked normally--
	print("cloned")
end)
1 Like

Nevermind, I realise the problem. The problem is you should be using serverstorage, not replicated storage.

It still doesnt clone into the backpack after trying your script and moving the handgun into serverstorage

Don’t use my script, use your except without replicated storage, and with serverstorage instead

Used my script except serverstorage instead of replicatedstorage and still doesnt clone

Did it print? are there any errors?

The print worked and there’s no errors in the output.

Try addid print(plr.Name) to the function and tell me what happens.

It does print my name but other than that it still doesnt clone into my backpack

It is possible that the gun isn’t archivable. Select the gun and go into the properties, enable “Archivable”. This will allow it to be cloned; without it, cloning isn’t possible.

The gun and all of its descendants are archivable but still doesnt clone

Try just changing the parent of the original model instead of cloning it. If you really need to clone it you can clone the original model outside of the player added back to serverstorage.

When a player joins, the character isn’t immediately added; however, the script immediately runs. This causes the gun model to be cloned and parented to the backpack, but shortly after the character loads. The gun is then deleted since there is a “new” character.

Here’s the solution:

plr.CharacterAdded:wait()

Add this to the line before you set the parent of the gun model.

6 Likes

Ok this actually works, thanks. I didn’t know that the gun clones itself to the backpack and shortly deletes itself after my character fully loaded