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

how to fix this kick after lose system like sushi shop simulator or gas station simulator?

Asked by 2 years ago

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)

0
What's the error? What part doesn't work Shawnyg 4330 — 2y

2 answers

Log in to vote
0
Answered by
Puppynniko 1059 Moderation Voter
2 years ago

You cant Kick another player from a local script change this script to a server script and place it inside of startercharacter

0
this is a script in a npc per_chuk 17 — 2y
Ad
Log in to vote
0
Answered by 2 years ago

Try using Humanoid.Died it fires when the character dies.

Answer this question