Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by
ImfaoXD 158
9 years ago

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

Log in to vote
4
Answered by 9 years ago

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!

0
Basically what I'd say. RadiantSolarium 35 — 9y
0
Thank you, ScriptFusion and RadiantSolarium. :) ImfaoXD 158 — 9y
0
NP ScriptFusion 210 — 9y
Ad

Answer this question