i have a player spawner that spawns the player when he joins, but i want when the player dies he teleports to a part named “location” ONLY when he dies, but the problem that the player teleports to the player spawner instead not to the location part
how can i do this ??
i made a script that checks for CharacterAdded but that also dont work it teleports to the player spawner not to the location part
local players = game:GetService("Players")
local location = -- Path to the location part
local function playerAdded(player)
local function died()
if not player:GetAttribute("HasDied") then
player:SetAttribute("HasDied", true)
end
end
local function characterAdded(char)
if player:GetAttribute("HasDied") then
char:PivotTo(location.CFrame)
end
char:WaitForChild("Humanoid").Died:Once(died)
end
player.CharacterAdded:Connect(characterAdded)
end
players.PlayerAdded:Connect(playerAdded)