How would I make a KOS Command? (I forgot how)

I’ve made a military NameTag before, and I forgot how to make KOS functions. How would I go about doing this?

	local prefix = settingsModule.Prefix
		
			plr.Chatted:Connect(function(Message)
				local SplitMessage = Message:split(" ")
				if SplitMessage[1] == prefix .. settingsModule.Commands.KillOnSight and table.find(settingsModule.Admins, plr.Name) then
					local NameOfPlayerToKOS = SplitMessage[2]
				local PlayerToKOS = game.Players:FindFirstChild(NameOfPlayerToKOS)
				local gui = game.Workspace:FindFirstChild(NameOfPlayerToKOS).Head.NameGui.Main.UserName
				gui.Text = "[KOS] " .. PlayerToKOS.Name
			elseif SplitMessage[1] == prefix .. settingsModule.Commands.ClearKOS and table.find(settingsModule.Admins, plr.Name) then
				local plrtoclear = SplitMessage[2]
				local PlayertoClear = game.Players:FindFirstChild(plrtoclear)
				local gui = game.Workspace:FindFirstChild(plrtoclear).Head.NameGui.Main.UserName
				gui.Text = PlayertoClear.Name
				end
		end)
		

Here’s a rough draft, but when I tried it, it didn’t do anything.

Is this a string or a table? I’m not sure what your admin system is like.

settingsModule is a modulescript with all the commands and stuff.

setup.Prefix = "!"

setup.Commands = {
	KillOnSight = "kos",
	ClearKOS = "clr",
	Authorise = "auth",
}

setup.Admins = {
	"Ey3r1sAlpha"
}

So, the command is like ‘!kos Ey3r1sAlpha’.

One of the main problems in your script is that FindFirstChild has no use if you try to index the children of it without checking if the child exists.
thing:FindFirstChild("seat").Child should be thing.seat.Child or you should check if “seat” exists.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.