Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Custom Money adding command isnt working, help?

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

4 comments

0

Why are there two parentheses around your function call? You also declared the Players service, no need to write game.Players, you must also use :Connect(). Lowercase :connect() is deprecated.

0

the two parentheses were accidental but removing them and re-capitalising did nothing to help

0

there is multiple if statements so i dont know which one you are talking about, also use the player id not the name.

0

After if msg:lower()

1 answer

✓ Accepted answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.