Info: this is for a meme game i am making (inferno is an admin) and i was making a command that gives everyone money, but in testing it doesnt work, everything is spelt correctly and works in the in-game console.
local function MoneyStorm() local allPlayers = game.Players:GetChildren() for i = 1, #allPlayers do allPlayers[i].leaderstats.despacitcoin.Value = allPlayers[i].leaderstats.despacitcoin.Value + 500 end end local players = game:GetService("Players") game.Players.PlayerAdded:connect(function(player) if player.Name == "xInferno_Dragonx" or player.Name == "pokemonzizzle8383" then player.Chatted:connect(function(msg) if msg:lower() == "MoneyStorm!" then MoneyStorm()() end end) end end)
EDIT: cant tell if this helps but the "despacitcoin" goes up by 20 every 10 seconds on a loop in another script
Edit 2: after the if i put Print("success") however it didnt print, meaning the problem must be before the if statment.
Edit 3: the error seems to be coming from "if msg:lower() == "MoneyStorm!" then" after doing more testing, however i cant seem to locate the problem
You should use ID's instead of their name and use string.lower().
local WhitelistedIDs = {} --[[ Example table: local WhitelistedIDs = {1, 1361134044} | Add a comma after each ID ]] local PlayerService = game:GetService("Players") local function MoneyStorm(player) player.Chatted:Connect(function(msg) if string.lower(msg) == 'moneystorm!' then --// Lowers chat for index, id in pairs(WhitelistedIDs) do --// Loops through WhitelistedIDs table if player.userId == id then --// If the matches one of the IDs in the table for index, plr in pairs(PlayerService:GetPlayers()) do --// Gets all players plr.leaderstats.despacitcoin.Value = plr.leaderstats.despacitcoin.Value + 500 --// Adds value end end end end end) end PlayerService.PlayerAdded:Connect(MoneyStorm)