I want to know how I can keep my shop safe from hackers/exploiters from changing prices or not paying any amount of money and getting them for free.

This is the code I have so far

hoverLableText.MouseButton1Click:Connect(function()
	game.Players.LocalPlayer.PlayerGui.Select:Play()
	--------------------------	
	-- Grabbing money value --
	--------------------------
	local money = game.Players.LocalPlayer.leaderstats.Money.Value
	-------------------------------
	-- Current displayed product --
	-------------------------------
	local vp = game.Players.LocalPlayer.PlayerGui.MainMenu.Screens:FindFirstChild("ShopFrame").ViewportFrame:GetChildren()[1]
	--------------------------------------------
	-- Current price of the displayed product --	
	--------------------------------------------
	local DisplayedPrice =tostring(game.Players.LocalPlayer.PlayerGui.MainMenu.Screens:FindFirstChild("ShopFrame").Price:FindFirstChild(tostring(vp) .. "Price").Text)
	--------------------------------------------
	-- Gets rid of the string values in money --
	--------------------------------------------
	local FilterdDisplayPrice = DisplayedPrice:gsub( "%W", "" )
	local CleanMoney = tonumber(FilterdDisplayPrice)
	--------------------
	-- What we bought --
	--------------------
	local indexList = require(game.ReplicatedStorage.IndexList)
	----------------------------------
	-- All custom functions we created
	----------------------------------	
	local FunctionModules = require(game.ReplicatedStorage.Functions)
	------------------------------------------
	-- Indexed function in functionMoudules --
	------------------------------------------	
	local indexed = FunctionModules.CheckAgainstWhitelistWithIndex(indexList,vp.Name)[1][1]

	-------------------------------
	-- Checks various conditions --
	-------------------------------	
	--Checks if gun is free
	if CleanMoney == nil then
		--Do nothing 		
	end
	--Checks if money is less then what user has and makes sure this is a paid gun
	if CleanMoney ~= nil then
		if money < CleanMoney and CleanMoney ~= nil then
		--Do nothing AND DO not give player this gun
		--Checks if money is == or > then needed money and makes sure it is not free and makes sure this gun can not be charged many times also makes sure it is not a consumble	
		elseif money >= CleanMoney and CleanMoney ~= nil and indexed == nil then
		game.Players.LocalPlayer.leaderstats.Money.Value = game.Players.LocalPlayer.leaderstats.Money.Value - CleanMoney
		local GunToLoadout = vp:Clone()
		GunToLoadout.Parent = game.ReplicatedStorage.Loadout
		table.insert(indexList,vp.Name)
		end
	end	
end)

5 comments

0

To make sure its not exploitable, check everything again on server

0

k ty so basicly what i am thinkng is that i should not even have the leader value in a local as it can be manipulated right and instead do the subtracting from the server as it is not visable. Is this a good idea?

0

You can leave it local, as long as you make all changes and checks via server(i also recommend checks on client), the exploiter can't change his or others money

0

My (messy) shop script I own, runs everything on the server, regardless of what the client passes thru. First, I check on the datastore (on the server) the value that the client passed me (for example, a pet named Teapot) to see if the client owns it. If it doesnt, it attempts to purchase it if theres enough money. If something goes wrong (or suceeds), the server notifys the client.

0

Thank you so much this really helps (= .