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

How do I make a Shop?

I would like to know how to make a Shop that you can buy an item with currency and then you can equip it and that you can only equip 1 item. Also when I teleport the players to the Map the game will give that person the items they equipped. So how do I do it?

1 answer

✓ Accepted answer

First, This is not a request site. its a site where you try to figure it out first then ask for help if you cant get it

A push in the right direction TO do this youll need some basic math and checking if the player has it.

Getting down to the actual code For buying things its simple, just use the event you want and use simple math to subtract that from the money. But we need to check it first!

local cost = 10

script.Parent.Touched:connect(function(hit)
	if hit:FindFirstChild("Humanoid") then
		If money >= cost then 
			--code
		end
	end
end

Pretty self explanatory. but how do we take money out if their value? Simple subtraction!

local cost = 10

script.Parent.Touched:connect(function(hit)
	if hit:FindFirstChild("Humanoid") then
		If money.Value >= cost then 
			money.Value = money.Value - cost
		end
	end
end

See? Simple! But what about putting it in with them? easy again, we need to adjust our code and add on to your other map/ spawning script

--Store script
local cost = 10

script.Parent.Touched:connect(function(hit) 
	if hit:FindFirstChild("Humanoid") then
		local plr = game.Players:GetPlayerFromCharacter(hit.Parent) -- this gets the player
		If money.Value >= cost then 
			money.Value = money.Value - cost
			TOOL:Clone().Parent = plr -- Lets put it in player for easy use
		end
	end
end
---------------------------------------------------------------------------
--Other script

--Code
for i, plr in pairs(game.PLayers:GetPlayers()) do
--Move
if plr:FindFirstChild("TOOL") then
plr.TOOL:Clone().Parent = plr.BackPack
end

And thats all! :D Hope i helped! If i did thumb up my answer and accept it!

if you do not know how to code do not ask for people to make it for you on this site

2 comments

2

it's funny how event though you say multiple times, this is not a request site, you still give him the requested code

0

I do that sometimes, lol.

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