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

How do i make this script only allow player to get one item and on death remove item?

This script is currently allowing the player to spam more then one item in there inventory which can be used for abuse.

It also allows the player to keep the item when they die and respawn, how do i make this script were it only allows the player to get one item and when they die they loose the item? Thanks for helping!

you=script.Parent.Parent.Parent.Parent.Parent
script.Parent.Text=tostring(script.Parent.ItemName.Value)..": "..tonumber(script.Parent.Cost.Value).." "..tostring(script.Parent.Currency.Value)
script.Parent.MouseButton1Click:connect(function()
if you:findFirstChild("leaderstats") then
if you.leaderstats[script.Parent.Currency.Value].Value>=tonumber(script.Parent.Cost.Value) then
game.Lighting[script.Parent.ItemName.Value]:Clone().Parent=you.Backpack
game.Lighting[script.Parent.ItemName.Value]:Clone().Parent=you.StarterGear
script.Parent.Selected=false
wait(2)
script.Parent.Selected=true
end
end
end)

5 comments

0

What is "you" defined as? Also, you shouldn't use Lighting as storage.

0

You is basically player,

0

And why are you getting you via 500 script.Parents?

0

im guessing because there is more them one item buttons in a frame so i have to put parents. when i put Localplayer the script breaks.

1 answer

✓ Accepted answer

You'd only clone the item in 'Backpack'. Cloning them into StarterGear will let them have the item again, as much as how many times it was cloned into backpack. Character dies, they lose everything in backpack. Character respawned, everything in StarterGear will be copied into backpack.

you=script.Parent.Parent.Parent.Parent.Parent
script.Parent.Text=tostring(script.Parent.ItemName.Value)..": "..tonumber(script.Parent.Cost.Value).." "..tostring(script.Parent.Currency.Value)
script.Parent.MouseButton1Click:connect(function()
if you:findFirstChild("leaderstats") then
if you.leaderstats[script.Parent.Currency.Value].Value>=tonumber(script.Parent.Cost.Value) then
game.Lighting[script.Parent.ItemName.Value]:Clone().Parent=you.Backpack
--StarterGear removed
script.Parent.Selected=false
wait(2)
script.Parent.Selected=true
end
end
end)

1 comment

0

There we go that was the problem, i really didnt know starterGear and backpack were not the same now i know thanks again for your help this worked!

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