I have these 2 admin commands I made a few hours ago.
Let me show you the first one, which is a command list (BTW, the script is in the GUI that I am cloning):
game.Players.PlayerAdded:connect(function(plr) plr.Chatted:connect(function(msg) if msg == ":cmds" then local clone = script.Parent:clone() clone.Parent = plr.PlayerGui end end) end)
And my second one is an infinite gold command:
game.Players.PlayerAdded:connect(function(plr) plr.Chatted:connect(function(msg) if msg == ":InfGold" and plr.Name == "groovydino" or plr.Name == "Player" or plr.Name == "dragonmaster4111" or plr.Name == "LimitedGoneWrong" 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)
The problem is, if I say :cmds (referring to the first script) the command list GUI does pop up, but for some reason, I get infinite gold, too. And I didn't even say :InfGold! What is the problem here and how can I fix it?
Your problem was with the second command. When you checked to see if the player was an admin, you used "or" without imbedding it in an "and". This means that if the player's name is equal to any name other than the first name statted, it will give them infinite gold anyways. To fix this, just put an open parenthesis after "and" and a closed parentheses before "then". However, we can make the script more efficient using a for loop to check if the player is an admin. Here's the finished script:
First Command:
PlayerAdded:connect(function(player) PlayerChatted:connect(function(msg) if msg == ":cmds" then --If you don't want this to be case--sensitive, then you can change this line to *if string.lower(msg) == ":cmds" then* local clone = script.Parent:Clone() clone.Parent = player.PlayerGui end end) end)
Second Command:
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)