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

Looking to make a kick on death with a delay?

Asked by 5 years ago

I have a script that kicks people when they die, but I want the kick to be delayed a second or two, I don't want it to be immediate since I have a death GUI I want them to see before they go. Any ideas? Thank you in advance, I'm very new to scripting.

1
wait(2) greatneil80 2647 — 5y

2 answers

Log in to vote
-1
Answered by
karlo_tr10 1233 Moderation Voter
5 years ago
Edited 5 years ago

Answers by greatneil80 and Nowaha are what you are looking for. Use delay after died function, here is how it should look like: (Normal script inside ServerScriptService)

local Delay = 2
local Reason = ""

game:GetService("Players").PlayerAdded:Connect(function(Player)
    Player.CharacterAdded:Connect(function(Character)
        Character:WaitForChild("Humanoid").Died:Connect(function()
            wait(Delay)
            Player:Kick(Reason)
        end)
    end)
end)
0
Ah, thank you! Everyone here is so helpful :D TheQuickestJimmy 2 — 5y
Ad
Log in to vote
0
Answered by
Nowaha 459 Moderation Voter
5 years ago

To make a delay anywhere in your code, you can use the wait() function.

wait(2), in example, will wait for 2 seconds before it continues with the code below it.

-- Code before waiting
wait(2)
-- After 2 seconds, everything below here will happen.

Answer this question