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

[Solved] How would i go by making this script give out cash when owner joins game?

Asked by 5 years ago
Edited 5 years ago

I'm trying to make this script give out cash to everyone when owner joins the game.

1for i, v in pairs(game.Players:GetPlayers()) do  -- gets all the players
2if v.Name == "A1exTatum" then  -- finds the owner
3v.leaderstats.Cash.Value = v.leaderstats.Cash.Value + 20  -- gives out cash
4 
5end
6end

2 answers

Log in to vote
3
Answered by 5 years ago

I would personally use your UserId, but the name works as well.

1game.Players.PlayerAdded:Connect(function(plr) --Detects when a player joins
2    if plr.Name == "A1exTatum" then --Checks if their name matches yours...
3        plr:WaitForChild("leaderstats"):WaitForChild("Cash").Value = plr.leaderstats.Cash.Value + 20 --Gives you the money
4    end
5end)
1
regular script or, local? i would assume regular but, just making sure A1exTatum 57 — 5y
1
Nvm got it working, Thanks! A1exTatum 57 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

You would need to make the function run upon a player joining.

1game.Players.PlayerAdded:Connect(function(player)
2  --anything here would run when a player joins
3end)
0
You'd also need to add an if-statement to see if the player name (or user id) is the same as the owner's player name. blarp_blurp645 63 — 5y

Answer this question