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.
01 | local player = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent |
02 | local price = 1 |
03 | local tool = game.Lighting:findFirstChild( "Teleport" ) |
04 |
05 | function picture() |
06 | script.Parent.Parent.Picture.Image = "http://www.roblox.com/asset/?id=51067285" |
07 | script.Parent.Parent.Price.Text = "$1" |
08 | end |
09 |
10 | function buy() |
11 | wait( 0.1 ) |
12 | local money = player.leaderstats.Coins |
13 | if money.Value > = price then |
14 | local a = tool:clone() |
15 | a.Parent = player.Backpack |
Thank you for helping me.
Make a bool value in the player, when they buy the item, make the value true, and add an if statement, eg.
1 | if player.Item.Value = = true then |
2 | print ( "All ready has item!" ) |
3 | elseif player.Item.Value = = false then |
4 | --script to buy the item. |
5 | 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!