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

How to make a ShopGui that you could purchase with currency?

Could anyone tell me how to make a shop GUI with currency? For instance... I want people to buy a speed coil with currency?

1 comment

0

Scripting helpers isn't a request site, you need to give us a script so we can help you with what's wrong with it.

1 answer

✓ Accepted answer

So first of all, you need to make a leaderstat folder in your player. You do this by putting this script into your workspace.

game.Players.PlayerAdded:connect(function(player)
	local leaderstat = Instance.new("Folder",player)
	leaderstat.Name = "leaderstats"
	local Coins = Instance.new("IntValue",leaderstat) -- change "Coins" to whatever you want
	Coins.Name = "Coins" -- Stat name -- change "Coins" to whatever you want
	Coins.Value = 10 -- Starting coins  -- change "Coins" to whatever you want
end)

Then after that, you need to go to the toolbox and get a speed coil or item you're trying to buy.

Making the Gui should be simple enough: Add a ScreenGui in the StarterGui in explorer. There, you put a button for opening/ closing the shop. You will also need a frame to open. In the frame you'll need a TextButton. The Button for Opening/Closing the shop should have a script looking like this:

local Button = script.Parent
local Frame = script.Parent.Parent.Frame

Frame.Visible = false
Button.MouseButton1Click:Connect(function()
	Frame.Visible = not Frame.Visible
end)

When you design your shop inside the frame, you need to insert a StringValue, IntValue and a localscript in the Textbutton. The IntValue should be renamed to "Price" and StringValue to the item you want to sell(in this case it is "SpeedCoil"). I will write the localscript later since I have no time right now... But I'm sure someone can help you.

UPDATE: I have made a localscript specifically for the Speed Coil... Just put this script inside the item Button.

----------[Scripted by Ghost40Z]

script.Parent.MouseButton1Click:Connect(function(player)
	local Button = script.Parent
	local Price = Button.Price
	local player = game.Players.LocalPlayer
	local leaderstat = game.Players.LocalPlayer.leaderstats
	if leaderstat.Money.Value >= Price.Value then
		leaderstat.Money.Value = leaderstat.Money.Value - Price.Value
		local ClonedCoil = game.ReplicatedStorage["Speed Coil"]:Clone()
		ClonedCoil.Parent = player.Backpack
	else
		print("Player doesn't have enough money...")
	end
end)

15 comments

0

Thank you so much! But how do you know what every script means?

0

Yes, I do know what they mean, and no problem!

0

Could you tell me how to script?

0

Sorry, I read your comment incorrectly. See the script with the "Frame.Visible = not Frame.Visible" is changing the frame visibility to the opposite, which means it is closing/opening a frame, that would in this case be the script for the button. The leaderstat script is just basically making a folder inside the player with their coin values(IntValue).

0

I am still very new to scripting, but I can add you on discord so you can ask me questions if you need anything simple.

0

I don’t have discord

0

Well, you can follow me on Roblox then.

0

Can you follow me too?

0

Sure.

0

Yay! You

0

How did you learn how to script and where?

0

I learned from youtube, I started learning 20 days ago for a project me and my friends wanted to do. We were making a suprise for our friend's Birthday, so I learned how to script. After that we actually set out to make an RPG game (25 people working on it) and now I'm here.

0

Wait do I put both of the scripts you sent me in one who?

0

Whole*

0

I have posted the Speed Coil localscript...Make sure the tool in your Replicated Storage is named "Speed Coil" so it works, for other items just change the name in the script and the price, Peace.

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