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)

6 comments
You should be using all local variables. On line 11 you are using a global function. connect is deprecated so use Connect as well.
dude you don't need semicolons
are you using R15 characters?
convert the script I gave you into a server one
Or you can use a easier method: make a gui button and when the player clicks it will save the CFrame and tp the player back to that pos after death
You'll need remotes and server script setting the pos