local data = game:GetService("DataStoreService")
local Level = data:GetDataStore("Level")
local Credits = data:GetDataStore("Points")
local XP = data:GetDataStore("XP")
game.Players.PlayerAdded:connect(function(plr)
---------------------------------------------------------------------------
local key = "user_"..plr.userId
local stats = Instance.new("IntValue",plr)
stats.Name = "leaderstats"
local level = Instance.new("IntValue",stats)
level.Name = "Level"
level.Value = Level:GetAsync(key) or 1
if plr and plr.PlayerGui.LevelGui then
game.Players[plr.Name].PlayerGui.LevelGui.Frame.Level.Text = "Level: " .. level.Value
end
local credits = Instance.new("IntValue",stats)
credits.Name = "Credits"
credits.Value = Credits:GetAsync(key) or 0
if plr and plr.PlayerGui.LevelGui then
game.Players[plr.Name].PlayerGui.LevelGui.Frame.Credits.Text = "Credits: " .. credits.Value
end
local xp = Instance.new("IntValue",stats)
xp.Name = "EXP"
xp.Value = XP:GetAsync(key) or 0
level.Changed:connect(function() Level:SetAsync(key, level.Value) end)
credits.Changed:connect(function() Credits:SetAsync(key, credits.Value) end)
xp.Changed:connect(function() XP:SetAsync(key, xp.Value) end)
-----------------------------------------------------------------------------
end)
Whenever I play the game, it gives me the error 'LevelGui is not a valid member of PlayerGui' on line 15, and even when I try printing the GUI in the console, it says that it was not found.
But I can clearly see the GUI on my screen???
Help is appreciated! Thanks! :D
