I'm using a regular script (Not LocalScript) and I want to have it check if the players ID is mine, then is will change Rank to Owner. I do not know how to check players who enter . I know using LocalPlayer is not working. This includes Data persistence. My problem is on line 17!
cashkey = "cash"
rankkey = "rank"
game.Players.PlayerAdded:connect(function(player)
stats = Instance.new("IntValue", player)
stats.Name = "leaderstats"
cash = Instance.new("IntValue", stats)
cash.Name = "Cash"
cash.Value = 0
rank = Instance.new("StringValue", stats)
rank.Name = "Rank"
rank.Value = "Visitor"
if game.Players.LocalPlayer.userId == 29413559 then
game.Players.LocalPlayer.leaderstats.Rank.Value = "Owner"
end
player:WaitForDataReady()
cash.Value = player:LoadNumber(cashkey)
rank.Value = player:LoadString(rankkey)
end)
game.Players.PlayerRemoving:connect(function(player)
if player.leaderstats.Cash.Value ~= 0 then
player:SaveNumber(cashkey, player.leaderstats.Cash.Value)
end
if player.leadersats.Rank.Value ~= "Visitor" then
player:SaveString(rankkey, player.leaderstats.Rank.Value)
end
end)
Also I don't want it to JUST check me! I want it to check every player. Would I need to use FindFirstChild() or something? Please explain your fix to me as well. Thank you.
