I'm pretty new to scripting so sorry if it's something that should be obvious. I am trying to make a level system in which the longer players play the higher the level they become. The only issue is that if there are multiple players in the server at once it counts everyone's XP and when the whole server reaches the lowest XP needed for a player to level up it levels up that player.
minutes = 0
xpRate = 5
function onPlayerEntered(newPlayer)
wait(.5)
local stats = Instance.new("IntValue")
stats.Name = "leaderstats"
local score = Instance.new("IntValue")
score.Name = "Money"
score.Value = 0
score.Parent = stats
stats.Parent = newPlayer
local level = Instance.new("IntValue")
level.Name = "Level"
level.Value = 1
level.Parent = stats
stats.Parent = newPlayer
local XP = Instance.new("IntValue")
XP.Name = "XP"
XP.Value = 0
XP.Parent = stats
stats.Parent = newPlayer
while minutes <= xpRate do
wait(60)
minutes = minutes + 1
score.Value = score.Value + 25
XP.Value = XP.Value + 5
if minutes == xpRate then
minutes = 0
xpRate = xpRate + 2
XP.Value = 0
level.Value = level.Value + 1
end
end
end
game.Players.ChildAdded:connect(onPlayerEntered)

2 comments
use Players.PlayerAdded, not ChildAdded
ChildAdded works unless you put something in Players yourself