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

How do you make a script that kicks after a humanoid is dead?

Asked by 2 years ago

So I have a boss fight place (1 player server) and I want to insert a script into the humanoid of the boss so that when it dies, after 30 seconds it kicks you out of the game with a custom kick message, how do I make such thing?

P.S. I'm a terrible scripter so please explain thoroughly!

0
Please try attempting it, and if it doesn't work you can come back and ask for help to make the script function the way you want it to. luluziluplayzROBLOX 61 — 2y

2 answers

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

Hey! I noticed the last answer was not working for you so I made a revised version. Put this in a normal Script inside of the NPC:

local hum = script.Parent.Humanoid
game.Players.PlayerAdded:Connect(function(Player)
    Player.CharacterAdded:Connect(function(Character)
        hum.Died:Connect(function(Death)
            wait(30)
            Player:Kick("You Died") -- Put your custom message here
        end)
    end)
end)
Ad
Log in to vote
0
Answered by
Aimarekin 345 Moderation Voter
2 years ago

Use the following:

Players.PlayerAdded - See Docs

Player.CharacterAdded - See Docs

Humanoid.Died - See Docs

Players:GetPlayerFromCharacter() - See Docs

Player:Kick() - See Docs

With these elements in mind, you can create the following example script:

game.Players.PlayerAdded:Connect(function(plr) -- Bind this function to when someone joins the game
    plr.CharacterAdded:Connect(function(char) -- Within that player, when it's character is added, bind this function
        char.Humanoid.Died:Connect(function() -- Then, within that character, search for the humanoid, and bind a function to when it dies
            wait(30) -- Optional, wait before kicking. Mind that the character may respawn during this period.
            plr:Kick("Custom Message") -- Kicks the player
        end)
    end)           
end)
0
Thank you so much!! Ghostinee 27 — 2y
0
For some reason it doesn't work, I placed the script inside the Boss NPC model, did I do something wrong? Ghostinee 27 — 2y
0
Hey! I noticed that the last persons answer was a little different from what you wanted so I made a revised version: Scryptio 64 — 2y

Answer this question