Making a revive system for my game!

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?

Possibly a table?

1 Like

you could put a object value on the player, make the value the part that the player touches.

when they die and if they buy it, then teleport the player to the value of that object value

2 Likes

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

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.