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)
i was thinking i could use the place id for it somehow
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)
thank you so much! what type of script should this be and where would i put it? (sorry still learning)
This should be a server script because LocalPlayer doesn’t exist on server and you can put it in ServerScriptService.
unfortunately its not working, i put my id in the place id but i am not teleporting anywhere
Oh sorry forgot to mention, you can’t teleport in studio, you actually have to test it in Roblox itself.
i have tried it ingame and it doesnt work
Does it give any errors in console?
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!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.