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

How can I make my shop better and exploit-free?

Asked by 5 years ago
Edited 5 years ago

Keep in mind that I'm a beginner at developing roblox games and have started to understand how codes work generally.

In my game: one of the major parts of the game is to make the shop system efficient and secure. Of course I have to make all features secure.

So far I've come up with this kind of shop system. In which the purchase event runs with the button(Currently this works for coins only. I haven't made the system check what kind of currency is going to be used yet)

When the buy button is pressed, the display price(display is supported with Ui with a script designed for the shop system itself. This menas there's going to be many scripts) is going to be subtracted from the players price. If the player doesn't have enough coins, a frame will pop up telling them. Else, It's going to do as the code does. After that, the corresponding item Ui with a script designed for the equipment system will be cloned to the weapon equipment scrolling frame.

It also comes with an addition of telling if the player has bought the item. I used a folder to make sure that everything which was bought is going to the specific folder.

(localscript)

-- Player vars

local Player = game.Players.LocalPlayer
local leaderboard = Player:WaitForChild("leaderstats")

-- services
local RS = game:GetService("ReplicatedStorage")

-- Events 
local EFolder = game.ReplicatedStorage:WaitForChild("EventsFolder")-- Brings the folder
local CPurchase = EFolder:WaitForChild("CoinsPurchase")
local OweItem = EFolder:WaitForChild("OwnedItem")
local Affordable = EFolder:WaitForChild("OwnedItem")


-- Buttons and item data
local button = script.Parent
local price = script.Parent.Parent.Price
local thisName = script.Parent.Parent.ItemNameview
local Purchased = script.Parent.Parent.PurchasedLabel

-- CheckItemsOwned folder 
local BoughtItems = game.ReplicatedStorage.BoughtItems


-- Purchase
button.MouseButton1Click:Connect(function()
    game.ReplicatedStorage.EventsFolder.CoinsPurchase:FireServer()

    if leaderboard.Coins.Value >= price.Value then
        leaderboard.Coins.Value = leaderboard.Coins.Value - price.Value
        local RSItem = RS:WaitForChild(thisName.Text)
        RSItem:Clone().Parent = BoughtItems
        local ThisUI = game.ReplicatedStorage.UIStore:WaitForChild(thisName.Text)
        local WeaponEquipment = Player.PlayerGui.Navigations.EquipmentFrame.WeaponsScroller
        ThisUI:Clone().Parent = WeaponEquipment
    end

    if BoughtItems:FindFirstChild(thisName.Text) then -- Check if the item is owned/purchased
        button.Visible = false
        Purchased.Visible = true
    else
        button.Visible = true
        Purchased.Visible = false   
    end

    if leaderboard.Coins.Value < price.Value then
        Player.PlayerGui.Navigations.ShopFrame.InsufficientDisplay.Visible = true
    end 
end)


Here comes the part which I haven't fully understood yet. Using the remoteevents. From what I understand, I have to set up a condition, which in this case is when I press the purchase button. When that condition triggers, I have to tell the remote event what to do. I think whatever code I write in the onserverevent is what I code I want to become legit. Do I think right?

-- folder
local EFolder = game.ReplicatedStorage.EventsFolder

-- services
local RS = game:GetService("ReplicatedStorage")

-- events
local CPurchase = EFolder.CoinsPurchase
local GPurchase = EFolder.GemsPurchase

-- functions

CPurchase.OnServerEvent:Connect(function(player) -- event for CPurchase
    print("event fired")    
    local Player = game.Players.LocalPlayer
    repeat wait() until Player
    local leaderboard = Player:WaitForChild("leaderstats")
    local price = Player.PlayerGui.Navigations.ShopFrame.ShopPreviewFrame.Price
    local thisName = Player.PlayerGui.Navigations.ShopFrame.ShopPreviewFrame.ItemNameview
    local BoughtItems = game.ReplicatedStorage.BoughtItems
    local button = Player.PlayerGui.Navigations.ShopFrame.ShopPreviewFrame.BuyButton
    local Purchased = Player.PlayerGui.Navigations.ShopFrame.ShopPreviewFrame.PurchasedLabel


    if leaderboard.Coins.Value >= price.Value then
        leaderboard.Coins.Value = leaderboard.Coins.Value - price.Value
        local RSItem = RS:WaitForChild(thisName.Text)
        RSItem:Clone().Parent = BoughtItems
        local ThisUI = game.ReplicatedStorage.UIStore:WaitForChild(thisName.Text)
        local WeaponEquipment = game.Players.LocalPlayer.PlayerGui.Navigations.EquipmentFrame.WeaponsScroller
        ThisUI:Clone().Parent = WeaponEquipment
    end

    if BoughtItems:FindFirstChild(thisName.Text) then
        button.Visible = false
        Purchased.Visible = true
    else
        button.Visible = true
        Purchased.Visible = false   
    end

    if leaderboard.Coins.Value < price.Value then
        game.StarterGui.Navigations.ShopFrame.InsufficientDisplay.Visible = true
    end 
end)

Is there any way to improve the whole entire thing? Leave comments below.

0
Just one problem: It's literally impossible to make a game exploit-free. DeceptiveCaster 3761 — 5y
0
Yap, people say using remote events prevent it but that's so wrong, there are some ways to do it, but you gotta go deep starmaq 1290 — 5y
0
As long as you make sure the server (normal Script) handles everything that could be exploited your fine and you can use remotes to communicate between the client and the server. gullet 471 — 5y
0
@gullet please give an example Stormtech6 2 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

I think it is fine but your money system could be upgraded using gui's and making the whole money function in a gui

0
An answer that should be a comment. Lol. DeceptiveCaster 3761 — 5y
0
Please give an example Stormtech6 2 — 5y
0
c o m m e n t p l s LoganboyInCO 150 — 5y
Ad
Log in to vote
0
Answered by
Mr_Pure 129
5 years ago

tl;dr

Understanding the concept of the title, I'm assuming you don't want your shop freely exploited.

There are two simple solutions for this.

(PLEASE NOTE I DID NOT READ ALL OF YOUR POST)

  1. Filtering enabled - this blocks all client to server communication vice versa unless granted through a key for example, a remoteevent.

  2. Be specific, if you don't want people to take items out of your store through scripts then make a check function so that when they're granted with the item you check there cash/currency to see if it has changed.

2.5. Put a cap on currency, if their cash magically went up 50k or more then you can add a script for that. give them a punishment/add them to a banlist, really anything you want to do.

0
"I'm assuming you don't want your shop freely exploited"? With the newest exploit technologies, ANYTHING can be freely exploited. DeceptiveCaster 3761 — 5y
0
1. I tried using remotevent. From what I understand any code I put on remoteevent onserverevent is what I want to be legit, but when I trigger it of using the buyButton the event is only fired and I don't see any changes with the players balance. So I had to put the function on the Onserverevent and the purchase script itself. Stormtech6 2 — 5y
0
2 - 2.5 please give an example Stormtech6 2 — 5y

Answer this question