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

Copy an item from Lighting to StarterPack?

I want to make a button that, when clicked, copies the weapon in Lighting to the player who clicked it's StarterPack (not Backpack).

Code:

local tool = script.Parent.Item.Value
local takable = true

function give(playerWhoClicked)
	if takable then
		game.Lighting["PizzaSword"]:clone().Parent = game.StarterPack
		takable = false
	end
end

script.Parent.ClickDetector.MouseClick:connect(give)

Thanks, Mex

1 answer

✓ Accepted answer

###No, do not store it in Lighting, it is unsupported by Roblox andServerStorage and ReplicatedStorage exist for these very reasons. If you clone it to StarterPack, you'd have to reset the player so they can get the item. Instead, place in their Backpack and StarterGear, so it persists even after death.

local tool = script.Parent.Item.Value
local takable = true

local function give(playerWhoClicked)
    if takable then
        local sword = game.ServerStorage["PizzaSword"]:Clone()
        sword.Parent = playerWhoClicked.Backpack
        sword:Clone().Parent = playerWhoClicked.StarterGear
        takable = false
    end
end

script.Parent.ClickDetector.MouseClick:Connect(give)

###On a side note, :connect() and :clone() are deprecated, use :Connect() and :Clone() instead.

1 comment

0

Awesome. thanks a lot!

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