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

Is there a way to modify this code to make it so the player can gain more money? [closed]

Asked by 6 years ago

So im making a game where we are given money every 10 seconds, and i want to add company's that players can buy and get more money from them WITHOUT droppers Here is the script for the money riser, please help me figure this out! Is there any way that I can add lines of code that check to see if the player owns the building "using a value" that gives more money upon money arrival time?

amount = 5
timedelay = 10
currencyname = "Cash" 
while true do
    wait(timedelay)
    for i,v in pairs(game.Players:GetPlayers()) do
        if v:FindFirstChild("leaderstats") and v then
            v.leaderstats[currencyname].Value = v.leaderstats[currencyname].Value + amount
        end
    end
end 
0
What you are saying is confusing, just use a simple Int value for how many companies are owned and add 5 for each building.... Idk what you are doing but this is the best I can do lol greatneil80 2647 — 6y

Closed as Not Constructive by User#19524

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
0
Answered by
tantec 305 Moderation Voter
6 years ago

Uhh, you could add StringValues inside of each the company's buildings, this stringvalue will have the player's name who owns it so when you do that you can do this in advance.

amount = 0 -- changed it to zero so i can times the amount of companies by 5 for money
timedelay = 10
currencyname = "Cash" 
while true do
    wait(timedelay)
    amount = 0
    for i,v in pairs(game.Players:GetPlayers()) do
    for _,b in pairs(game.Workspace:GetChildren()) do
        if b.Name == "Company" then
            if b.StringValue.Value == v.Name then
                amount = amount + 1
            end
        end
        end
    amount = amount * 5
        if v:FindFirstChild("leaderstats") and v then
            v.leaderstats[currencyname].Value = v.leaderstats[currencyname].Value + amount
        end
    end
end 
Ad