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

Struggling on Timed ban. Plz Help?

Asked by 4 years ago
Edited 4 years ago

Im kinda struggling on making a timed ban. I dont know where to start.

Here is the script so far.

local ds = game:GetService('DataStoreService')
local tempData = ds:GetDataStore('tempData')

local dev = {'CRAZYQUACKY84'}

local function PlayerArgument(args)
    for index , person in ipairs(plrManager:GetPlayers()) do
        if string.match(person.Name:sub(1,args:len()),args) then
            return person
        else
            warn("Player not found!")
        end
    end
end


local function RemainingTime(x)
    local plrBanTime = tempData(plrBanTime)

    x = plrBanTime - os.time()

    return x
end

game.Players.PlayerAdded:Connect(function(plr)
    for _,v in pairs(tempData) do
        if plr.Name == v then
            local plrBanTime = tempData(plrBanTime)
            if plrBanTime ~= 0 then
                plr:Kick('Remaining time'..RemainingTime)
            else if plrBanTime == 0 then
                    local UserId = plr.Id
                    tempData:Remove(UserId, plrBanTime)
                end
            end
        end
    end
end)

game.Players.PlayerAdded:Connect(function(plr, banmsg)
    if string.lower(banmsg:sub(1, 9)) == ':bantime3' then
        local commandSplits = string.split(banmsg:sub(10,-1),' ')
        local plrBanArg = PlayerArgument(commandSplits[1])
        local commandReason = banmsg:sub((11 + commandSplits[1]:len()),-1)
        local plrBanTime = 

        local UserId = plr.Id

        plrBanArg:Kick('You have been banned for 3 days for Violating Terms of Service \n Enforcer: \n Reason: '..commandReaon)

        pcall(function()
            tempData:SetAsync(tostring(UserId), plrBanTime, commandReason)
        end)
        tempData:SetAsync(tostring(UserId), plrBanTime, commandReason)
    end
end)
0
line 17 is completely wrong. First, that's not how you get the data from a datastore, and 2nd, you cant use a nil key SteamG00B 1633 — 4y
0
same with line 7 SteamG00B 1633 — 4y
0
Also, can you include your PlayerArgument function? It seems you've forgotten to add it. SteamG00B 1633 — 4y
0
k CRAZYQUACKY84 113 — 4y
0
Yh but is what i am doin correcr or nah CRAZYQUACKY84 113 — 4y

Answer this question