Hello when It comes to Lua. I'm pretty bad I must say, I've also been working on a "Respawn on death location" local script, basically simply wherever on the game you die you repsawn at the place you died at.
I'll leave some code snippets of what i've tried to make this happen.
local localplayer = game.Players.LocalPlayer local originalPos = game.Players.LocalPlayer.Character.Torso.CFrame game:GetService("RunService").RenderStepped:connect(function() local Player = game.Players.LocalPlayer if Player.Character.Humanoid.Health == 0 then localplayer.Character.Torso.CFrame = localplayer.Character.Torso.CFrame wait(7.25) localplayer.CFrame = originalPos end end)
Second Code Snippet - By a unknown person, may help if you are trying to help me fix my code above
--// CONSTANTS local Player = game.Players.LocalPlayer --// INACTIVE VARIABLES local Character local DeathPos local DeathConnection --// DEATH POS FUNCTION function getDeathPos() if Character:FindFirstChild("Torso") then DeathPos = Character.Torso.CFrame elseif Character:FindFirstChild("HumanoidRootPart") then DeathPos = Character.HumanoidRootPart.CFrame else print("No torso or humanoid found!") end DeathConnection:Disconnect(); DeathConnection = nil; end --// CHARACTER ADDED EVENT Player.CharacterAdded:Connect(function(character) --GET VARIABLES-- Character = character local humanoid = character:FindFirstChildOfClass("Humanoid") --TP PLAYER TO DEATHPOS-- if DeathPos then Character.Torso.CFrame = DeathPos end --ON DEATH CONNECTION-- if humanoid then DeathConnection = humanoid.Died:Connect(getDeathPos) else print("no humanoid found!") end end)
You are kind of over complicating it. You could just simply have a checkpoint follow the player two or three studs under their feet. You don't even need to have the checkpoint colliding. Just have the player step on the checkpoint as soon as they start the level, and then make the checkpoint non-colliding and have it follow the player wherever they go. (on the player's death pause the following function, as the checkpoint should be following the torso, and the body disconnects.) Anyway, i hoped this helped, and I'm sorry if this was not what you were looking for. Have a nice day!