Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to add an in-game store, where in-game items can be purchased with in-game currency?

I'm somewhat of a noob and only recently did I learn about GUIs and buttons.

How can I add an in-game store in my game, in which things can be purchased with the in-game money I'm adding into the game?

1 answer

Hello!

In order to be able to add an in-game store you need to have an ingame currency (e.g leaderstats currency), with that you also need to be able to have a button in which contains a script that subtracts the amount of ingame currency you would like your item to cost and that once the currency amount is subtracted a way for the script to reward the player (e.g rewarding the player a sword tool from ReplicatedStorage) as a LocalScript.

Here is a quick example following what I have stated above:

local Player = game.Players.LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SwordTool = ReplicatedStorage :WaitForChild("ClassicSword")
local Backpack = Player:WaitForChild("Backpack")

script.Parent.MouseButton1Click:Connect(function()
    if Player.leaderstats.Cash.Value >= 50 then -- Change 50 to the amount of cash a player required to have in order to be able to buy this
        SwordTool:Clone().Parent = Backpack
        Player.leaderstats.Cash.Value = Player.leaderstats.Cash.Value - 50
    end
end)

3 comments

0

This makes sense, thank you! What if, in my case, what the person is purchasing isn't an item, but rather another kind of script?

0

Hello! I am glad to see that what I have written made sense to you! I am trying to understand, in your case, what do you mean another kind of script?

0

Well my game is essentially the stock market but in ROBLOX, so basically, the in-game store would be where players can purchase new shares for a certain stock. If that makes any sense lol

This discussion is preserved as it was. New answers, comments, and votes are closed.