I've tryed so many things, It either bugged it or the player, was allowed to STILL buy it more then once.

local player = game.Players.LocalPlayer
local character = game.Workspace:WaitForChild(player.Name)
local money = player.leaderstats.Cash
local price = script.Parent.Parent.PriceValue.Value
local level = player.leaderstats.Level
local LEVEL = script.Parent.Parent.LevelRequired.Value
local tool = game.ReplicatedStorage.Purchase:FindFirstChild(script.Parent.Parent.ToolName.Value)
function click()
	script.Parent.Parent.Parent.Parent.Click:Play()
	if level.Value >= LEVEL then
		else
		script.Parent.Parent.PurchaseText.Text="Your level is to low!"
		script.Parent.Parent.PurchaseText.Visible=true
		wait(2)
		script.Parent.Parent.PurchaseText.Visible=false
		return
		end
		if player.Backpack:FindFirstChild(game.ReplicatedStorage.Purchase:FindFirstChild(script.Parent.Parent.ToolName.Value)) then
		script.Parent.Parent.Parent.Parent.Click:Play()
		script.Parent.Parent.PurchaseText.Text="You already have this Item!"
		script.Parent.Parent.PurchaseText.Visible=true
		wait(2)
		script.Parent.Parent.PurchaseText.Visible=false
		return
	else
		if money.Value >= price then
		money.Value=money.Value - price	
			tool:Clone().Parent=player.Backpack
			script.Parent.Parent.Parent.Parent.PurchaseSound:Play()
			script.Parent.Parent.PurchaseText.Text="Purchase success!"
			script.Parent.Parent.PurchaseText.Visible=true
			wait(2)
			script.Parent.Parent.PurchaseText.Visible=false
			else
			script.Parent.Parent.PurchaseText.Text="You don't have enough!"
			script.Parent.Parent.PurchaseText.Visible=true
			wait(2)
			script.Parent.Parent.PurchaseText.Visible=false
			end
		end
 	end
script.Parent.MouseButton1Click:connect(click)

3 comments

0

Why not use a if statement to check wither or not the Player already has the tool before allowing the player to purchase it?!?

0

This is extremely round about but with the lack of knowing how else to do this... You could set up a bool value that determines if the object has been purchased. If bool is true then player has purchased else player has not purchased give them the item.

0

Yep I would do what AZDev on that. It's the simplest way (that I know of) to make sure they don't have one.