I am trying to make a gui which shows the player how much xp they have.
At line 20 in the script which displays it, I get an error reading: “Players.Eh_Canadian0.PlayerGui.Backpack.Score:20: attempt to index nil with ‘Value’”
NOTE: You can ignore the unbanked and banked parts, they (probably) aren’t part of the problem (or solution)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList,false)
local player = game.Players.LocalPlayer
local leaderstats = player:WaitForChild("leaderstats")
-- Edit Score
local Unbanked = script.Parent.UnbankedScore
local Banked = script.Parent.BankedScore
local XP = leaderstats:FindFirstChild("XP")
local Rank = leaderstats:FindFirstChild("Rank")
local XPMax = (((Rank.Value*(Rank.Value - 1))/10) * 100) + 100
local XPGui = script.Parent:FindFirstChild("Experience")
while wait() do
Unbanked.UnbankedGold.Text = leaderstats:FindFirstChild("UnbankedGold").Value
Banked.BankedGold.Text = leaderstats:FindFirstChild("Gold").Value
if XP.Value >= XPMax then -- Line 20: "attempt to index nil with value"
XPGui.LVL.Text = "↑"
wait (1.5)
XPGui.LVL.Text = Rank.Value
XPGui.Requirements.Text = XP.Value .. "/" .. XPMax
XPGui.XPBar.Size = UDim2.new(XP/XPMax, 0, 1, 0)
else
XPGui.XPBar.Size = UDim2.new(XP.Value/XPMax, 0, 1, 0)
XPGui.Requirements.Text = XP.Value .. "/" .. XPMax
XPGui.LVL.Text = Rank.Value
end
end