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

Admin Scripts

When I make admins scripts, I start them like this but it doesn't work right. If I were to add an FF command and say it, it would give everyone a FF in the server. Even If I say something like ff/Jacobrw01. I don't know why. Here is how I start though;

local admins = {
["Jacobrw01"] = true;
["nws18"] = true;
["JEFFREY0770"] = true;
}

game.Players.PlayerAdded:connect(function(plr)
if admins[plr.Name] then 
plr.Chatted:connect(function(m)
if m:sub(1,5)=="kill/" then
m:sub(1,6)
for i,v in pairs(game.Players:GetChildren()) do
v.Character:BreakJoints()
end
end
end)
end
end)

This is roughly how I set it up on all my commands.

1 answer

✓ Accepted answer

local admins = {
["Jacobrw01"] = true;
["nws18"] = true;
["JEFFREY0770"] = true;
}

local function findPlayer(msg,findName)
	local seperate = msg:lower():sub(findName)
	for a,b in pairs(game.Players:GetPlayers()) do 
		if string.find(b.Name:lower(), seperate) then
			return b
		end
	end
	return false
end

game.Players.PlayerAdded:connect(function(plr)
	if admins[plr.Name] then 
		plr.Chatted:connect(function(m)
			if m:sub(1,5)=="kill/" then
				m:sub(1,6) -- This serves no purpose
				--[[for i,v in pairs(game.Players:GetChildren()) do 
					--Don't use this for loop, if you only want one person
					v.Character:BreakJoints()
				end
				--]]
				local plr = findPlayer(m,6)
				if plr then 
					plr.Character:BreakJoints()
				end
			end
		end)
	end
end)

1 comment

0

h                                                                                                                                                                                                                                                                                                                                                                                                               

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