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

Why is it not freezing the player or thawing as well as banning?

Asked by 6 years ago

I can kill players but I can't ice,thaw or ban them? No errors No nothing just does not work

Admins = {"johndeer2233", "doodmen123", "Player", "Player1"}
Banned = {}
prefix = "/"
function kill(target)
    if game.Players:FindFirstChild(target) then
        if game.Players:FindFirstChild(target).Character.Humanoid then
            game.Players:FindFirstChild(target).Character.Humanoid.Health = 0 
        end
    end
end

function ice(target)
    if game.Players:FindFirstChild(target) then
        if game.Players:FindFirstChild(target).Character.Torso then
            game.Players:FindFirstChild(target).Character.Torso.Anchored = true
        elseif game.Players:FindFirstChild(target).Character.LowerTorso then
            game.Players:FindFirstChild(target).Character.LowerTorso.Anchored = true
        end
    end
end

function thaw(target)
    if game.Players:FindFirstChild(target) then
        if game.Players:FindFirstChild(target).Character.Torso then
            game.Players:FindFirstChild(target).Character.Torso.Anchored = false
        elseif game.Players:FindFirstChild(target).Character.LowerTorso then
            game.Players:FindFirstChild(target).Character.LowerTorso.Anchored = false
        end
    end
end

function ban(target)
    if game.Players:FindFirstChild(target) then
        game.Players:FindFirstChild(target):Kick()
        table.insert(Banned,target)
    end
end
game.Players.PlayerAdded:connect(function(plr)
    for i,v in pairs(Banned) do
        if v == plr.Name then
            game.Players:FindFirstChild(v):Kick()
        end
    end
    plr.Chatted:connect(function(msg)
        for i, v in pairs(Admins) do
            if plr.Name == v then
                if msg:sub(1,5):lower() == prefix.."kill" then
                    kill(msg:sub(6))
                end
                if msg:sub(1,5):lower() == prefix.."ice" then
                    ice(msg:sub(6))
                end
                if msg:sub(1,5):lower() == prefix.."thaw" then
                    thaw(msg:sub(6))
                end
                if msg:sub(1,5):lower() == prefix.."ban" then
                    ban(msg:sub(6))
                end
            end
        end
    end)
end)

1 answer

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

The reason you can’t ban them is because you need to kick them when you say it and when they join, you have the function as player addded so it will only kick them when they join again. The freeze and thaw would also not work on R15 because torso is not a valid member of that model. I would find their humanoid and set their walkspeed and jumppower to 0 and set it back when it’s thaw. Hope I helped.

Ad

Answer this question