So...there is an orange line underneath "rankz", "xpz", and "xpn" on lines 45-47 and i cant fix it. I need this script for leveling up but when i gain enough xp to level up it doesnt work. The minimum amount of xp needed to gain a level is 700 and in this case i replaced "Level" with "Rank"
local rank = game:GetService("DataStoreService"):GetDataStore("Ranks")
local xp = game:GetService("DataStoreService"):GetDataStore("XP")
local axp = game:GetService("DataStoreService"):GetDataStore("AXP") --Stands for amount of XP needed to level up
function savedata(dataname, playerid, value)
game:GetService("DataStoreService"):GetDataStore(dataname):SetAsync(playerid, value)
end
game.Players.PlayerAdded:Connect(function(player)
local leader = Instance.new("Folder")
leader.Name = "leaderstats"
leader.Parent = player
local rankz = Instance.new("IntValue")
rankz.Value = rank:GetAsync(tostring(player.userId)) or 1
rankz.Name = "Rank"
rankz.Parent = player:WaitForChild("leaderstats")
local xpz = Instance.new("NumberValue")
xpz.Value = xp:GetAsync(tostring(player.userId))
xpz.Name = "XP"
xpz.Parent = player
local xpn = Instance.new("IntValue")
xpn.Value = axp:GetAsync(tostring(player.userId)) or 700
xpn.Name = "XpNeeded"
xpn.Parent = player
xpz.Changed:connect(function()
if player:WaitForChild("XP").Value >= player:WaitForChild("XpNeeded").Value then
rankz.Value = rankz.Value+1
xpn.Value= xpn.Value+700
savedata("Ranks",player.userId,rankz.Value)
savedata("XP",player.userId,xpz.Value)
savedata("AXP",player.userId,xpn.Value)
else
savedata("Ranks",player.userId,rankz.Value)
savedata("XP",player.userId,xpz.Value)
savedata("AXP",player.userId,xpn.Value)
end
savedata("Ranks",player.userId,rankz.Value)
savedata("XP",player.userId,xpz.Value)
savedata("AXP",player.userId,xpn.Value)
end)
end)
game.Players.PlayerRemoving:Connect(function(player)
savedata("Ranks",player.userId,rankz.Value)
savedata("XP",player.userId,xpz.Value)
savedata("AXP",player.userId,xpn.Value)
end)

2 comments
Why do you have the asterisks on lines 45-47?
those are the elements with the orange line underneath it. when i save it an orange line appears