Making new commands

Oh well, let me know if the script works.

Let’s gooo! It’s working. Question, is it possible to make it where if you say like like first 5 letters of the player’s name an action will happen? or do you got to say the entire username?

You can split it a bit more using a different split method and splitting only the first 5 letters. Pretty sure it was string.split / string.sub .

Good to hear that your system is workin! If you have any other questions, I am easily available almost 24/7 in Discord.

How would I do that?

			elseif SplitCommand[1] == ":ungod" or SplitCommand[1] == ":Ungod" then
				local TargetedPlayer = SplitCommand[2]
				local Name = game.Players:FindFirstChild(TargetedPlayer)
				Name.Character.Humanoid.Health = 100

Here one of my commands, how would I make it a string split??

function GetName(PartialName)
	local plrtable = {}
	for i,v in pairs(game.Players:GetChildren()) do
		plrtable[i] = v.Name
	end
	local length = string.len(PartialName)
	local sub = string.sub(PartialName,1,length)

	local target = nil
	for index = 1,#plrtable do
		local foundplr = string.sub(plrtable[index],1,length)
		if sub == foundplr then
			target = plrtable[index]
		end
	end
	return target
end

game.Players.PlayerAdded:Connect(function(Player)
	if Player:GetRankInGroup(15423675) >= 245 then
		Player.Chatted:Connect(function(Command)
			local SplitCommand = Command:split(" ")
			--Kill Player
			if SplitCommand[1] == ":kill" or SplitCommand[1] == ":Kill" then
				local TargetedPlayer = SplitCommand[2]
				local Name = game.Players:FindFirstChild(TargetedPlayer)
				Name.Character.Humanoid.Health = 0
				--Kill Player

				--Godmode
			elseif SplitCommand[1] == ":god" or SplitCommand[1] == ":God" then
				local User = string.sub(Command,7)
				local TargetedPlayer = SplitCommand[2]
				local Name = GetName(User)
				Name.Character.Humanoid.MaxHealth = 10000000000
				Name.Character.Humanoid.Health = 10000000000
				--Godmode

				--Ungodmode
			elseif SplitCommand[1] == ":ungod" or SplitCommand[1] == ":Ungod" then
				local User = string.sub(Command,7)
				local TargetedPlayer = SplitCommand[2]
				local Name = GetName(User)
				Name.Character.Humanoid.MaxHealth = 100
				Name.Character.Humanoid.Health = 100


			end
		end)
	end
end)

I did not add this function here, but check for :lower() as well in the username.

What in the… yeah for now Ima just keep it as is lol. I ain’t the best scripter, don’t fully understand it lol

Feel free to contact me in Discord Tiitus#3617 for additional help, incase you need that.

Thx u so much, ima keep watching tutorials on making admin commands and keep gettin better at scripting etc. Thx!

1 Like