Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make things appear in backpack (inventory) after purchase?

This is what I have so far. It takes out my money but doesn't give the item.

leaderboard script

game.Players.PlayerAdded:connect(function(plr)
    local stats = Instance.new("BoolValue",plr)
 stats.Name = "leaderstats"
 

  local cash = Instance.new("IntValue",stats)
 cash.Name = "Zims"
	 cash.Value = 100

	 local cash = Instance.new("IntValue",stats)
cash.Name = "Kills"
     cash.Value = 0
end)

local script to buy the item

local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function(click)
    if player.leaderstats.Zims.Value >= 10 then
        player.leaderstats.Zims.Value = player.leaderstats.Zims.Value - 10

        game.ServerStorage.Tools.Sword:Clone().Parent = player:WaitForChild("Backpack")
    end
end)

2 answers

-- make 2nd script's 7. line :
local sword = game.ServerStorage.Tools.Sword:Clone().Parent = player.Backpack

My answer is similar to your attempt and the answer by @Omerevkizel

Replace line 7 on your purchase script:

local sword = game.ServerStorage.Tools.Sword:Clone()
sword.Parent = player.Backpack
sword:Clone().Parent = player.StarterGear

This script makes a clone of the sword and puts it in the player's backpack. Then it clones the clone and puts that in the player's StarterGear, which will keep the sword from getting destroyed when the player dies.

This discussion is preserved as it was. New answers, comments, and votes are closed.