So im making a story game and i made an infinite lives gamepass but whenever the player would buy a life or have the gamepass it would always make them respawn at the spawn location, how can i make it so they respawn where they died?
1 Like
Best way I’d say is when the humanoid dies, store the humanoid root part’s cframe value somewhere (not in the script, and not in a value inside the characters model!), and on respawn, make the humanoid root part’s cframe to the value you stored previously
1 Like
local players = game:GetService("Players")
function refresh(player)
local cframe = player.character.HumanoidRootPart.CFrame
player:LoadCharacter()
player.Character.HumanoidRootPart.CFrame = cframe
end
game.Players.PlayerAdded:Connect(function(deadPlayer)
deadPlayer.CharacterAdded:Connect(function()
deadPlayer.Character.Humanoid.Died:Connect(function()
wait(game.Players.RespawnTime)
refresh(deadPlayer)
end)
end)
end)
6 Likes
As nxybi said, Make a cframe value and set everytime the humanoidrootpart cframe to the cframe value, When the player dies, just do wait(-- amount of seconds)
and tp him.
a script in serverscriptservice?
Yes, put a script in ServerScriptService. Then, put what I said in my other post. This should work.
can i see an example cause i dont really get what you mean