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

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

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 

1 comment

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

1 answer

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 

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