Hello, I am making a leaderboard that DataStores all the information and is updated when the players data is updated. Everything works fine, except for one issue. In lines 37 & 38, the script tells each certain leaderstat to give a certain amount of points to anybody who is an admin. The script works fine, but the problem is lvl.Value = lvl.Value + 1 is not firing. Instead, lvl.Value thinks that it is p, so therefore the admin levels go up 100 instead of 1. I could not figure out the issue with it, so hopefully somebody can.
Code:
local ds = game:GetService("DataStoreService"):GetDataStore("Points")
local lvls = game:GetService("DataStoreService"):GetDataStore("Level")
Admins = {"Player", "turtletowerz", "T3XLAlt", "Natenewt"} --add names
function onEntered(player)
local stats = Instance.new("IntValue")
stats.Name = "leaderstats"
local p = Instance.new("IntValue", stats)
p.Name = "Points"
local lvl = Instance.new("NumberValue", stats)
lvl.Name = "Level"
stats.Parent = player
if ds:GetAsync("Key" .. player.Name) then --Checks if the player has a save
p.Value = ds:GetAsync("Key" .. player.Name) --Set the cash value to the save
else
p.Value = 10 --If no save they start with 100. Change to a different value if you want
end
p.Changed:connect(function(save) --When the cash changes
ds:SetAsync("Key" .. player.Name, save)--Save
end)
if lvls:GetAsync("Key" .. player.Name) then
lvl.Value = ds:GetAsync("Key" .. player.Name)
else
lvl.Value = 1
end
p.Changed:connect(function(save)
lvls:SetAsync("Key" .. player.Name, save)
end)
for i=1,#Admins do
if player.Name == Admins[i] then
wait(0.1)
p.Value = p.Value + 100 --THIS IS NOT THE PROBLEM, THIS IS THE POINT VALUE
lvl.Value = lvl.Value + 1 --HERE IS THE PROBLEM. THIS WILL NOT WORK
end
end

1 comment
You're missing an end, I'm assuming that's because you didn't copy the whole script...