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

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

Asked by 5 years ago

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

Log in to vote
0
Answered by
DanzLua 2879 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

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.

0
Well, I tested this in Studio, and my money value is changed, but when I try to buy anything, it doesn't work. User#28502 0 — 5y
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. DanzLua 2879 — 5y
0
It seems my money value is kept at Game.Players.PlayerName.leaderstats.Money.Value. Is this what you mean? User#28502 0 — 5y
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. DanzLua 2879 — 5y
View all comments (5 more)
0
Ah, alright. I think I've fixed it. Thanks! User#28502 0 — 5y
0
@JoshGamingHQ1 Accept if it helped :p DanzLua 2879 — 5y
0
Yeah I feel kinda dumb now but I joined this website today and I don't know how to do that :/ User#28502 0 — 5y
0
But anyway I accept this answer. User#28502 0 — 5y
0
@JoshGamingHQ1 You have to click the button to accept xd DanzLua 2879 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

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

Answer this question