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

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

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

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

end
end

2 answers

✓ Accepted answer

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

game.Players.PlayerAdded:Connect(function(plr) --Detects when a player joins
	if plr.Name == "A1exTatum" then --Checks if their name matches yours...
		plr:WaitForChild("leaderstats"):WaitForChild("Cash").Value = plr.leaderstats.Cash.Value + 20 --Gives you the money
	end
end)

2 comments

1

regular script or, local? i would assume regular but, just making sure

1

Nvm got it working, Thanks!

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

game.Players.PlayerAdded:Connect(function(player)
  --anything here would run when a player joins
end)

1 comment

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.

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