The swords scripts are not going to the sword when a player buys a sword

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? A sword that keeps its scripts when a player buys that sword.

  2. What is the issue? When a player buys a sword, it goes to their backpack, but the sword scripts don’t, so the sword doesn’t function.

  3. What solutions have you tried so far? Looking at old games and comparing scripts.

local player = game.Players.LocalPlayer
local sword = game.ReplicatedStorage.AzureSword

script.Parent.MouseButton1Click:Connect(function()
    sword.Parent = player:WaitForChild("Backpack")
end)

Help appreciated! :smile:

FYI: I put this script into a TextButton (sword).

Put this in the GUI Local script

script.Parent.MouseButton1Click:Connect(function()
       game.ReplicatedStorage.GetSword:FireServer("AzureSword", script.Parent)
end)

Create a RemoteEvent named “GetSword” into the Replicated Storage then a script in the ServerScriptService with this inside of it

game.ReplicatedStorage.GetSword.OnServerEvent:Connect(function(player, sword, TextButton)
        local findsword = game.ReplicatedStorage:FindFirstChild(sword)

        if findsword then
              local newsword = findsword:Clone()
              newsword.Parent = player:WaitForChild("Backpack")
    
              for i,v in pairs(TextButton:GetChildren()) do      
                  v:Clone().Parent = newsword
              end
        end
end)

Actually I realized that wouldn’t work since the script needs to fire to the server hang on lemme fix it

*Should work now assuming the way you have it set up