Here is my code

--August 15 2020
--To act as a safe transaction
--
--Made by:Mikey2019d

--------------------
-- Index function --
--------------------

function map(tble,filter)
	local index = nil
	for i,v in pairs(tble)do
		if filter == v then
			index = i
		end 
	end
	return index
end

-------------------
-- OnServerEvent --
-------------------
game.ReplicatedStorage.PurchasingTransaction.OnServerInvoke = function(player,tool,inList)		
---------------	
-- Constants --
---------------	
	local tools = {
		"AK103",
		"AUGA3",
		"AUGA3PARA",
		"DRAGUNOVSVU",
		"EMP",
		"FALPARASHORTY",
		"FlashBang",
		"GLOCK17",
		"GLOCK18",
		"GROZA-1",
		"GROZA-4",
		"Grenade",
		"HONEYBADGER",
		"KRISSVECTOR",
		"KSG12",
		"L2A3",
		"M231",
		"M9",
		"M93R",
		"MP5K",
		"P90",
		"PPSH-41",
		"PortableRadar",
		"REMINGTON700",
		"REMINGTON870",
		"SmokeGrenade",
		"TurretGun",
		"UMP45"
	}
	local ToolPrices = {
		0,
		500,
		1100,
		1550,
		50,
		2000,
		15,
		200,
		0,
		2300,
		2800,
		15,
		3600,
		3800,
		6500,
		3800,
		4000,
		600,
		1200,
		4500,
		4750,
		4850,
		22,
		7500,
		15000,
		7,
		120,
		9000
	}
local price = ToolPrices[map(tools,tostring(tool))]
local players = player	
local money = player:FindFirstChild("leaderstats").Money.Value
local purchases = game.ReplicatedStorage.Purchases:GetChildren()
local Auth1 = map(purchases,tostring(player.Name) .. tool)
	--Check if weapon is not aldready purchased and make sure player has enough money	
	if money > price then
		player:FindFirstChild("leaderstats").Money.Value = player:FindFirstChild("leaderstats").Money.Value - price
		local toolModel = game.Workspace.Tools:FindFirstChild(tostring(tool)):Clone()
		toolModel.Name = tostring(player.Name) .. toolModel.Name
		toolModel.Parent = game.ReplicatedStorage.Purchases
		local recipt = math.random(math.random(10000000,math.random(10000000,99999999)))
		local id = Instance.new("NumberValue")
		id.Value = recipt
		id.Parent = toolModel
		return recipt
	else
	
	end
end

3 comments

0

idk make leaderstats and datastore it and if on the leaderstats u put Purcased and then if you have one of the leaderstats numbervalue and then do script:Destroy() ik u prob wont understand anything ut i have to go soon so i gotta write fast.

0

Make a localscript that makes the gui not come up if they purchase

0

use datastores to save their purchase history/save that if they bought it