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.
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)
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.