So I have a boss battle game, I want to insert a script into the boss humanoid so that when it’s killed it kicks you out of the game after like 40 seconds or something, how can I make such a thing?
(If it helps, the game is a 1 player server only).
So I have a boss battle game, I want to insert a script into the boss humanoid so that when it’s killed it kicks you out of the game after like 40 seconds or something, how can I make such a thing?
(If it helps, the game is a 1 player server only).
local players = game:GetService("Players")
local npc = script.Parent
local npcHumanoid = npc.Humanoid
npcHumanoid.Died:Connect(function()
for _, player in ipairs(players:GetPlayers()) do
player:Kick("The NPC has died!")
end
end)
Should be as simple as this.
Thank you! How do I make it so that it kicks you after a few seconds (time that I set) instead of kicking you instantly after the boss has died?
npcHumanoid.Died:Connect(function()
task.wait(1) --Change 1 to desired length of time in seconds.
for _, player in ipairs(players:GetPlayers()) do
player:Kick("The NPC has died!")
end
end)
Thank you so so much! This helped a lot!!