So, what this script does is it saves stats, makes level gui above your head, etc. But, I ran into an issue. Upon adding "level.Value = OkAwesome:GetAsync(plr.UserId) or 0" to my script nothing past that point would work. This is the issue because if I get rid of it it magically works again. Here is my code: also im not very good at scripting so a lot of things probably look unreadable for people that know how ok here
local DataStore = game:GetService("DataStoreService") local OkAwesome = DataStore:GetDataStore("OkSoLetsSeeIfThisWorks") game.Players.PlayerAdded:Connect(function(plr) local leaderstats = Instance.new("Folder",plr) leaderstats.Name = "leaderstats" local level = Instance.new("IntValue",leaderstats) level.Name = "Level" level.Value = OkAwesome:GetAsync(plr.UserId) or 0 local stats = Instance.new("Folder",plr) stats.Name = "Stats" local currentExperience = Instance.new("IntValue",stats) currentExperience.Name = "currentExperience" currentExperience.Value = OkAwesome:GetAsync(plr.UserId) or 0 plr.CharacterAdded:connect(function(character) local levelGui = game.ReplicatedStorage.levelGui:Clone() levelGui.Parent = character.Head levelGui.TextLabel.Text = "Level "..level.Value character.Humanoid.Died:Connect(function() local tag = character.Humanoid:FindFirstChild("creator") if tag ~= nil then local player = tag.Value local reward = 1 local statz = player:WaitForChild("Stats") statz.currentExperience.Value = statz.currentExperience.Value + reward end end) end) level.Changed:connect(function(v) plr.Character.Head.levelGui.TextLabel.Text = "Level "..v OkAwesome:SetAsync(plr.UserId, level.Value) end) currentExperience.Changed:connect(function(v) plr.PlayerGui.xp.exp.Text = currentExperience.Value.." / 10" if v == 10 then level.Value = level.Value + 1 currentExperience.Value = 0 end OkAwesome:SetAsync(plr.UserId, currentExperience.Value) end) end) game.Players.PlayerRemoving:Connect(function(plr) local currentExperience = plr.Stats.currentExperience local level = plr.leaderstats.Level OkAwesome:SetAsync(plr.UserId, currentExperience.Value) OkAwesome:SetAsync(plr.UserId, level.Value) end)