i make a code like this but it fells like it have a error
local TeleportService = game:GetService("TeleportService") local h = script.Parent.Humanoid local n = script.Parent h.Changed:connect(function() if h.Health <= 0 then -- when the entity died wait(2) script.Parent:Destroy() for i,v in pairs(game.Players:GetPlayers()) do print(v) TeleportService:Teleport(5489981012, v) -- teleport back to my game v:Kick("Lost due to manager is dead. Teleporting to a new game") end end end)
You cant Kick another player from a local script change this script to a server script and place it inside of startercharacter
Try using Humanoid.Died
it fires when the character dies.