I am making an obby that doesn’t have checkpoints, so I created invisible/hollow parts inside of a folder inside of workspace named “Revives” is there a way for me to make it track the last part the player touched and then prompt them a dev product to revive from that part’s vector?
You can track the last piece the player touched by storing the position in a variable. With each touch, you can update this position and teleport the player to it after they purchase the dev product.
Example:
local lastTouchedPart = nil
local reviveParts = game.Workspace.Revives:GetChildren()
for _, part in ipairs(reviveParts) do
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
lastTouchedPart = part.Position
end
end)
end
local function revivePlayer(player)
if lastTouchedPart then
player.Character:SetPrimaryPartCFrame(CFrame.new(lastTouchedPart))
end
end