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

How do I make a Shop? [closed]

Asked by
Sei4or -3
9 years ago

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?

Closed as Not Constructive by evaera

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
3
Answered by 9 years ago

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!

1local cost = 10
2 
3script.Parent.Touched:connect(function(hit)
4    if hit:FindFirstChild("Humanoid") then
5        If money >= cost then
6            --code
7        end
8    end
9end

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

1local cost = 10
2 
3script.Parent.Touched:connect(function(hit)
4    if hit:FindFirstChild("Humanoid") then
5        If money.Value >= cost then
6            money.Value = money.Value - cost
7        end
8    end
9end

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

01--Store script
02local cost = 10
03 
04script.Parent.Touched:connect(function(hit)
05    if hit:FindFirstChild("Humanoid") then
06        local plr = game.Players:GetPlayerFromCharacter(hit.Parent) -- this gets the player
07        If money.Value >= cost then
08            money.Value = money.Value - cost
09            TOOL:Clone().Parent = plr -- Lets put it in player for easy use
10        end
11    end
12end
13---------------------------------------------------------------------------
14--Other script
15 
View all 21 lines...

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
it's funny how event though you say multiple times, this is not a request site, you still give him the requested code theCJarmy7 1293 — 9y
0
I do that sometimes, lol. rexbit 707 — 9y
Ad