Change place on death script

is it possible to make it so if you die you return to a place, and i dont mean a checkpoint, like i have 2 places in my game, one is the lobby and you get teleported into the other place, but i want to have where when i die, i will be put back into the original place (the lobby)

1 Like

i was thinking i could use the place id for it somehow

1 Like

From what I can tell, you want to make a story game in that case. You can detect when the player dies, and teleport them, I also added a delay if you want some kind of death screen:

local TeleportService = game:GetService("TeleportService")

local PlaceId = 1234567890
local DelayTime = 2

game.Players.PlayerAdded:Connect(function(plr)
	local Character = plr.Character or plr.CharacterAdded:Wait()
	local Humanoid = Character:FindFirstChild("Humanoid")
	
	plr.GetPropertyChangedSignal(Humanoid, "Health"):Connect(function()
		if Humanoid.Health == 0 then
			task.wait(DelayTime)
			TeleportService:Teleport(PlaceId, plr)
		end
		end)
end)
3 Likes

thank you so much! what type of script should this be and where would i put it? (sorry still learning)

2 Likes

This should be a server script because LocalPlayer doesn’t exist on server and you can put it in ServerScriptService.

1 Like

unfortunately its not working, i put my id in the place id but i am not teleporting anywhere

1 Like

Oh sorry forgot to mention, you can’t teleport in studio, you actually have to test it in Roblox itself.

1 Like

i have tried it ingame and it doesnt work

1 Like

Does it give any errors in console?

1 Like

haha i dont know how i managed it but i put the wrong place id in but i put the right one in and it works now, thank you so much for your help!

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.