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

How to compare a string to children in a folder?

Asked by 3 years ago

how? im trying to make a kill script so if i say like ;kill soni it will kill sonichfan

1 answer

Log in to vote
0
Answered by
NGC4637 602 Moderation Voter
3 years ago

what i think you can do is this server script:

local admins = { 
    1, -- user ids lol
    2,
    3,
}

game:GetService("Players").PlayerAdded:Connect(function(plr)
    if not table.find(admins, plr.UserId) then return end -- if he not an admin then this script will just be like nope
    plr.Chatted:Connect(function(msg) -- if an admin chatted
        if string.find(msg, ";kill") then -- if they said ;kill (insert player name) 
            for i,v in ipairs(game:GetService("Players"):GetPlayers()) do -- search all players
                if string.find(v.Name, string.sub(msg,6,-1)) then -- if there is a player with the name the admin specified (shortforms allowed)
                    local OmaeWaMuShindeiru = v.Character -- their character
                    local Nani = OmaeWaMuShindeiru:FindFirstChildWhichIsA("Humanoid") -- their character's humanoid
                    if not Nani then return end -- if no humanoid the script be like nope
                    Nani.Health = 0 -- kill the humanoid
                    Nani:ChangeState(15) -- in case changing health doesn't work for some reason, we change their humanoids state to the dead state
                end
            end
        end
    end)
end)
0
baka -me to me sonichfan 62 — 3y
0
weebs greatneil80 2647 — 3y
Ad

Answer this question