Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

All admin commands require a player's name and I don't want some of them to?

Asked by
awfulszn 394 Moderation Voter
8 years ago
Edited 7 years ago

Okay, I am making an admin script, but on commands, such as rejoin and reset it requires a players name, and I don't want them commands to have that. Only kick and kill should have it. i.e. ;kick mosski123

Here is my code;

01local Admins = {
02    ["19498972"] = true,
03    ["1540993"] = true,
04    ["46641586"] = true
05}
06 
07local prefix = ';'
08 
09local commandTable = {}
10 
11 
12function findPlayer(name)
13    for _, player in ipairs(game.Players:GetPlayers()) do
14        if player.Name:lower() == name:lower() then
15            return player
View all 54 lines...
0
You're only connecting the chatted event to admins. You should connect the chatted event to all and then check if the player is admin when specific commands are run. AZDev 590 — 8y
0
That's not the problem... awfulszn 394 — 8y
0
They don't appear to be set up like that though..? Could you be more specific and clarify about what you're asking? TheeDeathCaster 2368 — 8y
0
Basically, I have four commands, but they all require a target player to work. On the commands *rejoin* and *reset*, I want them to just be a command and only target the local player. awfulszn 394 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

I suggest you use String Manipulation. To be specific: string.sub(). What this done is it takes out a specificied section out of a string. This means that you can assign the player as a seperate variable by using string.sub().

For example, if you wanted to kill a player, do:

local target = string.sub(message, 6)

The above will take out anything said after ;kick or ;kill.

Ad

Answer this question