Your code:
local Players = game:GetService("Players")
local admins = {"WatsPlayzROBLOX"}
local leader = game.Players.LocalPlayer:WaitForChild("leaderstats")
local isAdmin = leader:WaitForChild("isAdmin")
Players.PlayerAdded:Connect(function(player)
if player.Name == admins then
player.leaderstats.isAdmin.Value = 1
print("Player "..player.Name.." is an admin.")
else
print("Player"..player.Name.."is not an admin.")
player.leaderstats.isAdmin.Value = 0
end
end)
server code in serverscriptservice
local Players = game:GetService("Players")
local admins = {"WatsPlayzROBLOX"}
Players.PlayerAdded:Connect(
function(player)
for i, v in pairs(admins) do
if v == player.Name then
player.leaderstats.isAdmin.Value = 1
print("Player " .. player.Name .. " is an admin.")
else
print("Player" .. player.Name .. "is not an admin.")
end
end
end
)
Why my code would work:
player.leaderstats.isAdmin.Value = 1You can only add leader stats value in a server script, so that's why I added a remote event.
if player.Name == admins then -- this would not work because you have to loop through the admin table first
player.leaderstats.isAdmin.Value = 0 0 is default and you cant change it in local script
also check are easily exploitable
1 comment
.