When I join, I’m supposed to get the value 4 since I’m the owner, however, it’s error.
Script:
local saveData = game:GetService("DataStoreService"):GetDataStore("ezdsf,dkfdsdjsdojdskhdskdnsk")
function setAdminLevel(userid,level)
local name = game:GetService("Players"):GetPlayerByUserId(userid)
name.Administrative.AdminLevel.Value = level
saveData:SetAsync(userid,level)
end
game.Players.PlayerAdded:Connect(function(plr)
if saveData:GetAsync(plr.UserId,level) then
setAdminLevel(plr.UserId,level)
elseif plr.UserId == game.CreatorId then
setAdminLevel(plr.UserId,4)
end
end)
local saveData = game:GetService("DataStoreService"):GetDataStore("ezdsf,dkfdsdjsdojdskhdskdnsk")
function setAdminLevel(userid,level)
local name = game:GetService("Players"):GetPlayerByUserId(userid)
name.Administrative.AdminLevel.Value = level
saveData:SetAsync(userid,level)
end
game.Players.PlayerAdded:Connect(function(plr)
if plr.UserId == game.CreatorId then
setAdminLevel(plr.UserId,4)
elseif saveData:GetAsync(plr.UserId,level) then
setAdminLevel(plr.UserId,level)
end
end)
Nope, I placed the CreatorId condition at the start since if you place the saveData:GetAsync(plr.UserId,level) at the start, then it will obviously not work since everyone will have a save level (if the player has played the game more than once) meaning that your code will only check if your PlayerId is equal to the CreatorId if you still don’t have a saved data. If you place the CreatorId at the start, then the script will always check if the PlayerId is equal to the CreatorId.