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

How Can I Make A Script That Purchase One Time Only If A Player Already Have The Same Item?

How can I make a script that purchase one time only when a player already have the item? Like for example; if you buy a link sword and you decided to buy the same one again, but you can't since you already have that link sword in your backpack. And also they will lose coins for how much they spend depending on how much the item costs. So how can I do that? Also this is for a normal script. Not a local script. Please help me guys.

local player = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent
local price = 1 
local tool = game.Lighting:findFirstChild("Teleport") 

function picture() 
script.Parent.Parent.Picture.Image = "http://www.roblox.com/asset/?id=51067285" 
script.Parent.Parent.Price.Text = "$1" 
end 

function buy()
wait(0.1)
local money = player.leaderstats.Coins
if money.Value >= price then 
local a = tool:clone() 
a.Parent = player.Backpack
else 
end 
end 




script.Parent.MouseButton1Down:connect(buy) 
script.Parent.MouseEnter:connect(picture)

Thank you for helping me.

1 answer

✓ Accepted answer

Make a bool value in the player, when they buy the item, make the value true, and add an if statement, eg.

if player.Item.Value == true then
print("All ready has item!")
elseif player.Item.Value == false then
--script to buy the item.
end

Define you variables first, and this needs to be edited to work obviously.

If this helps you, accept this answer, it gives us both rep!

3 comments

0

Basically what I'd say.

0

Thank you, ScriptFusion and RadiantSolarium. :)

0

NP

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