My DataStore and leaderboard worked perfectly before, except now I added two new IntValues -- ExperienceNeeded(inside Experience value in leaderboard) and MaxLevel (inside Level value in leaderboard). I have attempted to make a system that lets players level up and gain money based on how many points they have. I am getting these errors:
22:33:52.708 - Experience is not a valid member of IntValue 22:33:52.709 - Script 'Workspace.lvlDealer', Line 3 22:33:52.709 - Stack End
22:35:24.233 - Can't parse response 22:35:24.235 - Script 'Workspace.Leaderboard', Line 53 22:35:24.235 - Stack End
(I've put comments on the lines which have errors on them for convenience.)
Leaderboard script:
local levl = game:GetService('DataStoreService'):GetDataStore('Level') local EXP = game:GetService('DataStoreService'):GetDataStore('Experience') local mon = game:GetService('DataStoreService'):GetDataStore('Money') local pnts = game:GetService('DataStoreService'):GetDataStore('Points') local expn = game:GetService('DataStoreService'):GetDataStore('ExperienceNeeded') function load1(plr) --loads players credits return levl:GetAsync(plr.userId) or levl:SetAsync(plr.userId, 1) and 0 end function load2(plr) --loads exp function will either set or gets them from last time return EXP:GetAsync(plr.userId) or EXP:SetAsync(plr.userId, 0) and 0 end function load3(plr) --loads exp function will either set or gets them from last time return mon:GetAsync(plr.userId) or mon:SetAsync(plr.userId, 0) and 0 end function load4(plr) --loads exp function will either set or gets them from last time return pnts:GetAsync(plr.userId) or pnts:SetAsync(plr.userId, 0) and 0 end function load5(plr) return expn:GetAsync(plr.userId) or expn:SetAsync(plr.userId, 83) and 0 end game.Players.PlayerAdded:connect(function(plr) --player joins local ls = Instance.new("IntValue",plr) ls.Name = "leaderstats" local lvl = Instance.new('IntValue', ls) lvl.Name = 'Level' lvl.Value = load1(plr) local ml = Instance.new("IntValue", plr) ml.Name = "MaxLevel" --changes the value from the load function ml.Value = 99 local xp = Instance.new('IntValue', ls) xp.Name = 'Experience' xp.Value = load2(plr) local en = Instance.new("IntValue", xp) en.Name = "ExperienceNeeded" en.Value = load5(plr) local money = Instance.new("IntValue", ls) money.Name = 'Money' money.Value = load3(plr) local points = Instance.new("IntValue", ls) points.Name = 'Points' --changes the value from the load function points.Value = load4(plr) while true do wait(5) levl:UpdateAsync(plr.userId, function() return plr.leaderstats.Level.Value end) EXP:UpdateAsync(plr.userId, function() return plr.leaderstats.Experience.Value end) mon:UpdateAsync(plr.userId, function() return plr.leaderstats.Money.Value end) pnts:UpdateAsync(plr.userId, function() return plr.leaderstats.Points.Value end) expn:UpdateAsync(plr.userId, function() return plr.leaderstats.Experience.ExperienceNeeded.Value end) end end) game.Players.PlayerRemoving:connect(function(plr) --saves it when player leaves levl:UpdateAsync(plr.userId, function() return plr.leaderstats.Level.Value end) EXP:UpdateAsync(plr.userId, function() return plr.leaderstats.Experience.Value end) mon:UpdateAsync(plr.userId, function() return plr.leaderstats.Money.Value end) pnts:UpdateAsync(plr.userId, function() return plr.leaderstats.Points.Value end) expn:UpdateAsync(plr.userId, function() return plr.leaderstats.Experience.ExperienceNeeded.Value end) end)
dealer script (gives experience and money based on how many points you earned during a round):
local gt = game.Workspace.gameRunner.gameTime local Debounce = false game.Players.PlayerAdded:connect(function(plr) wait(1) local p = plr.leaderstats.Points.Value local m = plr.leaderstats.Money.Value local e = plr.leaderstats.Experience.Value if gt.Value == 1 and Debounce == false then Debounce = true m = m + p/2 e = e +p p = p - p wait(1) Debounce = false end end)
lvldealer script (awards a level when the exp = expneeded, and makes it so you cant go above level 99):
game.Players.PlayerAdded:connect(function(plr) wait(1) local e = plr.leaderstats.Experience.Value local l = plr.leaderstats.Level.Value local ml = plr.MaxLevel.Value local en = plr.Experience.ExperienceNeeded.Value if e == en then l = l+1 e = e - en en = en*1.10409 end if l == ml then en = nil end end)
I know there's a lot of code here, but it would mean so much to me if somebody could fix this. I don't know what to do. Thank you :)
You are doubling variable names. For one you are overwriting the "en" datastore with a new IntValue.
Edit:
local en = game:GetService('DataStoreService'):GetDataStore('ExperienceNeeded') local en = Instance.new("IntValue", xp) local en = plr.leaderstats.Experience.ExperienceNeeded.Value
You need to change these variables to different ones, otherwise they overwrite the last one stated.