How to add a auto Money Giver after 20 seconds

Hello Scripters! I’m trying to figure out how to make a function which allows a player to receive Money every 10 Seconds, Below is the script I’m currently using, By the way I’m not a scripter at all lol.

	wait(.5)
	local stats = Instance.new("IntValue")
	stats.Name = "leaderstats"

	local score = Instance.new("IntValue")
	
	score.Name = "Money"
	score.Value = 0

	score.Parent = stats	
	stats.Parent = newPlayer
end

game.Players.ChildAdded:connect(onPlayerEntered)

2 Likes

while true do
wait(10)
score.Value = score.Value + 5 --put any amount of money you want in there
end)

2 Likes

Thanks! but where do I put that line of script exactly?

	wait(.5)
	local stats = Instance.new("IntValue")
	stats.Name = "leaderstats"

	local score = Instance.new("IntValue")
	
	score.Name = "Money"
	score.Value = 0

	score.Parent = stats	
	stats.Parent = newPlayer 

while wait(20) do
score.Value += 20 
end
end


game.Players.ChildAdded:connect(onPlayerEntered)
2 Likes

Didn’t Work, It completely removed the leaderstats :confused:

Hey, sorry but #help-and-feedback:scripting-support is not a spoon feeding channel(am pretty sure it’s not allowed anyway), meaning we won’t be able to just paste you the ready code. @BurgerBurner gave you the code you use to give the player 5 cash every 10 seconds, you put that after your script already made the leaderboard.

1 Like
game.Players.PlayerAdded:Connect(function(player)
local MoneyFolder = Instance.new("Folder")
MoneyFolder.Name = "leaderstats"
MoneyFolder.Parent = player

local MoneyValue = Instance.new("IntValue")
MoneyValue.Parent = MoneyFolder
    while wait(10) do
          MoneyValue.Value =   MoneyValue.Value +1
    end
end)

Its creating a folder (leaderstats) puting it in the player
then you create a value (Money) and after ten seconds you + 1 to the value

1 Like

Developer hub is a great tool, you are also welcome to use the devforums but people do expect that you have some coding knowledge, Also keep in mind that lua works from the top, all the way to the bottom. You would put that code under where the values are created/set. @watermill12

I don’t know why it keeps removing the whole leader stats, but it’s still not working… I’ll just ask some of my friends so don’t worry about it :confused:

1 Like

Where do you put the script? Did you create a folder named leaderstats?

Yes I did, But for some reason it all gets removed

Maybe you have a Virus in your game? Maybe a Free Model, or a Plugin?

Hm, removed? Could you show me your explorer? (Leaderstats shown)?

I just checked and it seems to be fine, Lemme open a new tab and make a new game and see
(or maybe im doing everything wrong)

bandicam 2020-10-24 12-17-49-856 bandicam 2020-10-24 12-17-34-050

So this is what I have so far

Ohh, the original script had a little fail. Try doing "MoneyFolder.Name = “leaderstats”

By the way if you see these red lines, they don’t mean it’s something good :slight_smile:

IT WORKED! thanks for noticing that lol!

If something worked, mark it as a solution so others know.

yea sorry that was a mistype oops