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

Help w/ commands?

This is a commands script. How would I make it so only a certain person could say ";restetplace" or ";reset place"?

StartClone=game.Workspace.World:clone()
Prefix=";"
game.Players.PlayerAdded:connect(function(Plr)
	Plr.Chatted:connect(function(Msg)
		print(Plr.Name.." Said Something!")
		print(Msg)
		if Msg:sub(1,1)==Prefix then
			Msg=Msg:lower()
			MsgS=Msg:sub(2)
			print(MsgS)
			if MsgS=="resetplace" or MsgS=="reset place" then
				game.Workspace.World:remove()
				StartClone.Parent=game.Workspace
				StartClone=game.Workspace.World:clone()
			elseif MsgS=="settings" then
				Plr.PlayerGui.Tools.Settings.Visible=true
			elseif MsgS=="cmds" or MsgS=="commands" then
				Plr.PlayerGui["CommandGui's"].Gui.KeyCharacter.Text="Prefix - "..Prefix
				Plr.PlayerGui["CommandGui's"].Gui.Visible=true
			end
		end
	end)
end)

1 answer

✓ Accepted answer

I would do it like this:

StartClone = game.Workspace.World:clone()
Prefix = ";"
local Admins = {"NlLES","PreyStar"}


function checkAuthority(name)
	for a,v in pairs(Admins) do --For every Admin in the table
		if v == name then --If the name matches a name in the table
			return true
		end
	end
	return false --It will only get to this point if it hasn't returned true already.
end


game.Players.PlayerAdded:connect(function(Plr)
	Plr.Chatted:connect(function(Msg)
		print(Plr.Name.." Said: ".. Msg)
		if Msg:sub(1, 1) == Prefix then
			Msg = Msg:lower()
			local MsgS = Msg:sub(2)
			print(MsgS)
			if (MsgS == "resetplace" or MsgS == "reset place") and checkAuthority(Plr.Name) then
				game.Workspace.World:remove()
				StartClone.Parent = game.Workspace
				StartClone = game.Workspace.World:clone()
			elseif MsgS == "settings" then
				Plr.PlayerGui.Tools.Settings.Visible = true
			elseif MsgS == "cmds" or MsgS == "commands" then
				Plr.PlayerGui["CommandGui's"].Gui.KeyCharacter.Text = "Prefix - "..Prefix
				Plr.PlayerGui["CommandGui's"].Gui.Visible = true
			end
		end
	end)
end)

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