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
8 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 8 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!

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
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 — 8y
0
I do that sometimes, lol. rexbit 707 — 8y
Ad