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

How can i put 2 currencies in this script?

Asked by 3 years ago
local chars = game.ReplicatedStorage:WaitForChild("Characters")

local classNames = {"Accessory", "Shirt", "Pants", "ShirtGraphic", "BodyColors"}


game.Players.PlayerAdded:Connect(function(plr)

    local ls = Instance.new("Folder", plr)
    ls.Name = "leaderstats"

    local cash = Instance.new("IntValue", ls)
    cash.Name = "Cash"
    cash.Value = 0

    local chars = Instance.new("Folder", plr)
    chars.Name = "OwnedCharacters"
end)


game.ReplicatedStorage.CharacterRE.OnServerEvent:Connect(function(plr, isBuying, character)

    if not chars:FindFirstChild(character) then return end

    if isBuying and not plr.OwnedCharacters:FindFirstChild(character) then

        local price = chars:FindFirstChild(character).Price.Value
        local plrCash = plr.leaderstats.Cash

        if price <= plrCash.Value then

            plrCash.Value -= price

            chars[character]:Clone().Parent = plr.OwnedCharacters
        end


    elseif not isBuying and plr.OwnedCharacters:FindFirstChild(character) and plr.Character and plr.Character:FindFirstChild("Humanoid") then

        for i, descendant in pairs(plr.Character:GetDescendants()) do

            if table.find(classNames, descendant.ClassName) or descendant:IsA("Decal") and descendant.Parent.Name == "Head" then

                descendant:Destroy()
            end
        end


        for i, descendant in pairs(plr.OwnedCharacters[character]:GetDescendants()) do

            if table.find(classNames, descendant.ClassName) then

                descendant:Clone().Parent = plr.Character

            elseif descendant:IsA("Decal") and descendant.Parent.Name == "Head" then
                descendant:Clone().Parent = plr.Character.Head
            end
        end
    end
end)

1 answer

Log in to vote
0
Answered by 3 years ago
game.Players.PlayerAdded:Connect(function(plr)

    local ls = Instance.new("Folder", plr)
    ls.Name = "leaderstats"

    local currencieOne = instace.new("IntValue")
    currencieOne.Name = "NameOfCurrenci"
    currencieOne.Value = 0
    currencieOne.Parent = Is

    local currencieTwo = instace.new("IntValue")
    currencieTwo.Name = "NameOfCurrenci"
    currencieTwo.Value = 0
    currencieTwo.Parent = Is

    local cash = Instance.new("IntValue", ls)
    cash.Name = "Cash"
    cash.Value = 0

    local chars = Instance.new("Folder", plr)
    chars.Name = "OwnedCharacters"
end)

depending on what the script does and why you wanted two new Currencie, you modify the rest of the script with them added now

0
There I made a mistake, the name of the leaderstats variable is "ls", I put "is". horacioMiquen 15 — 3y
0
Fix it when you use the script horacioMiquen 15 — 3y
Ad

Answer this question