Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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)

1 comment

0

What's the error? What part doesn't work

2 answers

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

1 comment

0

this is a script in a npc

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

This discussion is preserved as it was. New answers, comments, and votes are closed.