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

How do I make a script where certain people get cash as soon as they join?

I'm working on a tycoon and I have some testers that I want to receive cash instantly when they join so that the testing is faster. Any suggestions?

2 answers

✓ Accepted answer

So lets say that cash is located inside the player under leaderstats and is named Money.

First we need to set up a playeradded event, then we check if the player's name is one of your testers, if so we can set the player's money.

game.Players.PlayerAdded:Connect(function(plr)
	if plr.Name=="DanzLua" or plr.Name=="JoshGamingHQ1" then
		plr.leaderstats.Money.Value=1000000
	end
end)

If the money value isn't located inside leaderstats then simple change the path to it after the if statement.

You can also check for their user ids instead of their username using the UserId property of player in the if statement.

9 comments

0

Well, I tested this in Studio, and my money value is changed, but when I try to buy anything, it doesn't work.

0

@JoshGamingHQ1 then check where your script decides whether you have enough money to buy the item. You didn't provide where your server sided money value is kept.

0

It seems my money value is kept at Game.Players.PlayerName.leaderstats.Money.Value. Is this what you mean?

0

@JoshGamingHQ1 Well that's where I assumed it was being kept, but you said it wouldnt let you buy anything so you have to check where the buying script checks to see if you have enough.

0

Ah, alright. I think I've fixed it. Thanks!

0

@JoshGamingHQ1 Accept if it helped :p

0

Yeah I feel kinda dumb now but I joined this website today and I don't know how to do that :/

0

But anyway I accept this answer.

0

@JoshGamingHQ1 You have to click the button to accept xd

We can include it when you add the leaderstat.

game.Players.PlayerAdded:Connect(Function(Player)
	local leaderstats = Instance.new("BoolValue") -- It doesn't have to be a bool value, just using it as a place holder. 
	leaderstats.Parent = Player 
	local cash = Instance.New("IntValue") 
	cash.Parent = leaderstats
	cash.Value = 500 -- This is the value they will start at.
end

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