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

SOLVED! Ban command not working. Using a DataStore editor plugin works but command doesn't?

Asked by 4 years ago
Edited 4 years ago

I remade the kick script on https://developer.roblox.com/en-us/api-reference/function/Player/Kick into a ban script. I used DataStores to store the banned player. When I use a DataStore Editor, I can add the person. But when I use the command, it doesn't work. Here is my script:

01    --ban command
02local Players = game:GetService("Players")
03 
04local ban = "/ban"
05 
06local DataStoreService = game:GetService("DataStoreService")
07 
08local DataStore = DataStoreService:GetDataStore("myDataStore")
09 
10local function onOwnerChatted(player, message)
11    if message:sub(1, ban:len()):lower() == ban:lower() then
12        local name = message:sub(ban:len() + 1)
13        local playerToban = Players:FindFirstChild(name)
14        if playerToban then
15            local success, eror = pcall(function()
View all 40 lines...
01--checking for banned person on different script when they join (this works)
02local DataStoreService = game:GetService("DataStoreService")
03local DataStore = DataStoreService:GetDataStore("myDataStore")
04game.Players.PlayerAdded:Connect(function(player)
05    local banned
06    banned = DataStore:GetAsync(player.UserId.."-banned")
07    if banned == true then
08        player:Kick("You are banned from this game by the owner!")
09        print(player.Name.." is banned.")
10    else
11        print(player.Name.." is not banned")
12    end
13end)
0
If it's not working, then it should be printing the "eror" message? If it does print it, do you mind posting it alongside your code? killerbrenden 1537 — 4y
0
It does not print the error message. TheWaildug 55 — 4y
0
I rewrote the code and now it works TheWaildug 55 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

I followed AlvinBlox's video on making an admin command format and put my code into there and now it works! https://www.youtube.com/watch?v=ZJE_xTzOdLs.

Admin script can be found here: roblox.com/library/5052993019/e

Ad

Answer this question