I have some admin commands, but I only need to show you 1 for this problem:
game.Players.PlayerAdded:connect(function(plr) plr.Chatted:connect(function(msg) if msg == ":InfGold" and plr.Name == "Player" or plr.Name == "dragonmaster4111" or plr.Name =="LimitedGoneWrong" or plr.Name == "groovydino" then local stats = plr:FindFirstChild("leaderstats") if stats ~= nil then local gold = stats:FindFirstChild("Gold") if gold ~= nil then gold.Value = 999999999 end end end end) end)
On line 4, is there any way I can change that to make it better? And I am NOT sure about this, but I think line 4 has a problem with the "or" part. Help?
Add a table with all the names and instead of doing gold.Value = 99999999999
do gold.Value = math.huge
. Math.huge is basically infinity.
admin = {"Player", "Player1", "dragonmaster4111", "LimitedGoneWrong", "groovydino", "LordDragonZord"} game.Players.PlayerAdded:connect(function(plr) plr.Chatted:connect(function(msg) for _,adminname in pairs(admin) do if msg == ":InfGold" and plr.Name == adminname then local stats = plr:FindFirstChild("leaderstats") if stats ~= nil then local gold = stats:FindFirstChild("Gold") if gold ~= nil then gold.Value = math.huge end end end end end) end)
Hope it helps!
A much more efficient way to do this would be to run the for loop in PlayerAdded so that we do not run a for loop every time we want to process a message. This will reduce a lot of lag depending on the length of your admin list.
local admins = {"Player", "Player1", "dragonmaster4111", "LimitedGoneWrong", "groovydino", "aquathorn321"} game.Players.PlayerAddded:connect(function(player) for i,v in pairs(admins) do if v == player.Name then player.Chatted:connect(function(msg) if msg ==":InfGold" then --If you don't want this to be case-sensitive, then you can change this line to *if string.lower(msg) == ":infgold" then* local stats = player:FindFIrstChild("leaderstats") --We don't need if statements checking to see if stats or gold exists, because the code will return an error and stop running on its own. local gold = stats:FindFirstChild("Gold") gold.Value == 999999999 end end break --end the loop if the player is recognized as an admin end end end)