Easy Written By sebse456

Making Custom Commands Created on: 16-10-2019

Make your own custom commands

Create a script

Add a script into ServerScriptService.

Make a function that fires once a player is writing a message

player.Chatted fires when a player writes in chat.

game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(msg)
	
	end)
end)

Make the script check if the message starts with the command prefix

game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(msg)
		if string.sub(msg, 0,1) == "(your command prefix)" then
		end
	end)
end)
		

string.sub takes a part of a string string. The string is a variable called "msg". So when we use string.sub(msg, 0,1), we only look at the first letter of the string. If the player writes "Hello", it's gonna end the script, but if the player writes "/hello", it's gonna continue into the if statement.

Make your command

game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(msg)
		if string.sub(msg, 0,1) == "(your command prefix)" then
		
		
			if string.sub(msg, 2) == "reset" then
				player:LoadCharacter() -- This is just and example. You can use whatever command you'd like
			end
		end
	end)
end)

Easy Written By sebse456

See sebse456's profile on Roblox

Discussion