Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to compare a string to children in a folder?

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

1 answer

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)

2 comments

0

baka -me to me

0

weebs

This discussion is preserved as it was. New answers, comments, and votes are closed.