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
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)
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)