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

How can I get an event to occur when an argument equals a certain value?

I am currently making an admin module for my new game. I set the chat so it sets an argument for every space in the chat. I started off with a simple kick command, but instead of the chat reading "~kick", it would kick a player as long as there was a first argument (whether or not it was a valid command). Here is my module script:

local prefix = "~"
local admin = {}
local cmds = {}
cmds[1] = prefix.. "Kick"

game.Players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(msg)
		local args = string.split(msg, " ")
		local cmd = args[1]
		local target = args[2]
		local stringText = args[3]
--CommandStart----------------------------------------------------
		if args[1] == string.lower(cmds[1]) or string.upper(cmds[1]) then
			--kick function here
		end
--CommandEnd------------------------------------------------------
	end)
end)

If I worded it badly, I am simply saying that the function will run even if the first argument isn't "~kick".

1 answer

✓ Accepted answer

I don't really get what you're saying. But I do see a mistake in your code. I think you want to check if args[1] is equal to string.lower(cmds[1]) or if args[1] is equal to string.upper(cmds[1]). In order to do that you need to have the args[1] == check in the comparison before and after the or.

Like this:

if args[1] == string.lower(cmds[1]) or args[1] == string.upper(cmds[1]) then

1 comment

0

Thank you, I'll give that a shot

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