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

My kick player admin commands doesn't work?

Asked by 4 years ago
Edited 4 years ago

I made a kick command for my admin commands for my game i made and it didn't work. Under line 22

01local function Notify(Player,String,Code)
02    game.ReplicatedStorage.NotificationEvent:FireClient(Player,String,Code)
03end
04game.Players.PlayerAdded:Connect(function(Player)
05    if Player:IsFriendsWith(game.CreatorId) or Player.UserId == game.CreatorId then
06wait(8)
07     game.ReplicatedStorage.NotificationEvent:FireClient(Player,"Welcome "..Player.Name.." you are admin. Prefix is /","E")
08    local prefix = "/"
09    Player.Chatted:Connect(function(Message)
10        local sub = string.sub(Message,1,1)
11        if sub == prefix then
12                local split = string.split(Message,prefix)
13                local lower = string.lower(split[2])
14            if lower == "r6" then
15                    require(script.R6).load(Player.Name)
View all 44 lines...

1 answer

Log in to vote
1
Answered by 4 years ago

After separating the prefix from the rest of the message as shown in your first split variable you proceed to use string.lower to turn the remaining string into lowercase letters. Well the thing is that the remaining string you have left after using string.split doesn't match with your if statements for instance

1local split = string.split("/kick DeUltimate23","/")
2local lower = string.lower(split[2])
3print(lower)

I am pretty sure this would print (kick DeUltimate23) and as you see it doesnt match your if statements.

One way to fix this is using string.find or split the whitespace from the command from message after the first split.

The string.find method can be done like this

1if string.find(string.lower(split[2]),"kick") then
2    --Do your thing here
3end

Hopefully you understood my explanation, and it might also be that I am wrong or there is an easier solution to this. Anyways good luck

0
You rock dude! I have seen you answer many questions, and they all seem right to me, I have been upvoting! JailBreaker_13 350 — 4y
0
Thanks! :D DeUltimate23 142 — 4y
Ad

Answer this question