The idea of my script is to click an on screen GUI and it will put a weapon inside the players Backpack and then the GUI will remove itself. The code is inside of a Localscript and it works perfectly when I test it in 'Play' mode but in 'Online' Mode the sword will appear in the users inventory but will make no sounds and you're unable to swing the sword itself.
Here's the code:
wait(1)
local player = game.Players.LocalPlayer
local sw = game.ReplicatedStorage.ClassicSword
function onButtonClicked()
if player:FindFirstChild("Backpack", 10) then
sw:Clone().Parent = player.Backpack
wait(0.1)
script.Parent:remove()
end
end
script.Parent.MouseButton1Down:connect(onButtonClicked)
Any help will be appreciated to be able to stop the models from seemingly randomly becoming broken!

3 comments
First of all, use Destroy(), remove() is deprecated. connect is also deprecated, use Connect insead. I don't think the problem lies in the script, but in the sword itself. It may have something to do with FilteringEnabled. I suggest using a different sword to see if that works. If it does, then it is a problem with the sword and not the script.
I've tried a large range of swords but they all seem to experience the same problem after being cloned. They work perfectly when put in the Starterpack but break when cloned and awarded to the player.
I think you’ll need to add a script to ServerScripts and a RemoteEvent in ReplicatedStorage along with the weapon that will get cloned to the backpack