I am trying to clone an accessory from a folder in the player’s backpack into their character but I’m getting this error pop-up everytime I want it to clone.
Local Script:
characterAddedRemote.OnClientEvent:connect(function()
local currentHat = currentHatFolder:GetChildren()
for i,v in pairs(currentHat) do
cloneCurrentHatRemote:FireServer(v, player.Character)
end
end)
Why are both of the code snippets the exact same in your post?
If it’s supposed to be like that. Both OnClientEvent and :FireServer() cannot be used on a server-script.
This makes no sense whatsoever as you can just do this on the server side. If client triggers it, use a remote event and tell server to do it anyway. You do not even need a characterAddedRemote as that also makes no sense, there is a CharacterAdded event.
This again is a waste of time and also allows easy exploitability of items, just have server listen to when their character is added and put the items there…
The first return value of a RemoteEvent in FireServer() is the player whose client fired it, so hat would be the second argument received. @Wunder_Wulfe is correct in that this approach is futile either way though.
This is your problem. When you try to send an instance over a remote event, it does not actually send a copy of that instance but instead a reference to that instance. If the accessory does not also exist on the server, this will not work. (Even if this pattern did work it would be horrible from a security perspective though, as players could wear anything)