#Teleport Not Working after the character died to a laser

5 messages · Page 1 of 1 (latest)

gentle wave
#

I Have problem with Teleport
The Teleport button won't teleport the character back to spawn after i died to a laser or after i reset character and it says "TpBackToSpawn is not a valid member of Workspace "Workspace"

Here's the script :

local button = script.Parent
local spawnPoint = game.Workspace.TpBackToSpawn

local function onButtonClick()
if spawnPoint then
local character = game.Players.LocalPlayer.Character
if character then
character:SetPrimaryPartCFrame(spawnPoint.CFrame)
end
else
print("Spawn point not found!")
end
end

button.MouseButton1Click:Connect(onButtonClick)

proper trench
#

@gentle wave

#

The problem is

#

sometime in studio,player load faster more than the parts

#

so what you need is :WaitForChild()