Hello! I'm currently trying to create a simulator which includes levels! I'm trying to get the current level and divide it by 2 then send it out as the "AddPoints" RemoteEvent. I don't know why it isn't working but I got no error messages. When I add a point with the function for adding points (jumping) it goes to 1 and gets stuck and it doesn't let me jump to increase anymore points. I have no clue, please help!
game.Players.PlayerAdded:Connect(function(player)
local Folder = Instance.new("Folder", player)
Folder.Name = "leaderstats"
local Points = Instance.new("IntValue", Folder)
Points.Name = "Points"
local Level = Instance.new("IntValue", Folder)
Level.Name = "Level"
Level.Value = 1
end)
game.ReplicatedStorage.AddPoints.OnServerEvent:Connect(function(plr) local points = plr.leaderstats.Points local levels = plr.leaderstats.Level points.Value = levels.Value / 2 end)
game.Players.PlayerAdded:Connect(function(plr) wait(0.1) local points = plr.leaderstats.Points local levels = plr.leaderstats.Level
while wait() do
if points.Value >= (10 * (levels.Value)) then
levels.Value = levels.Value + 1
points.Value = 0
game.ReplicatedStorage.LevelUpGui:FireClient(plr)
end
end
end)
Thanks! Best of regards, Exore/Frogsaregood12

3 comments
Are there any errors in output?
Is all this code one script?
Please format your code.