Create a price value

So Im trying to create a gui with a price value in it but the players can exploit that right so how do i make it so they cant or have the price value on the server.

1 Like

You can use a RemoteEvent and send in what the player is trying to buy as an argument. Then on the server side of the RemoteEvent, you handle whether the player has enough currency for the item or not, if they do, you handle what to do afterwards.

Once again, do not send in the price as an argument. Have the price somewhere inside the server script.

2 Likes

Make a module with all the prices, then require it with the local script.
Ex:
Module:

Local Values = {
["Gamepass1"] = 200,
["Gamepass2"] = 400
}
return Values

LOCAL:
require the module: local Module = require ...
name the button after the gamepass name
and then you can just do: Textlabel.Text = Values[Button.Name] (button.Name == Gamepass1 or 2)

1 Like

Something like this:

Module:

local Values = {
    ["Item1"] = 200,
    ["Item2"] = 400,
    -- Add more game passes and their prices here
}
return Values


locally:

local GamePassPrices = require(game.ServerScriptService.GamePassPrices) 

local button = script.Parent 
local textLabel = button:FindFirstChild("TextLabel") 

button.MouseButton1Click:Connect(function()
    local gamePassName = button.Name
    local price = GamePassPrices[gamePassName]
    if price then
        textLabel.Text = "Price: " .. price
    else
        textLabel.Text = "Invalid game pass"
    end
end)


1 Like

No, this is still exploitable. Make the check on the server using a RemoteEvent. Checking the value and then the actions that follow that should occur on the server only as well.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.