The script that this runs on is located in ServerScriptService and the part is in the specified folder, but still I don’t know what causes this error to occur. Please help! The error and code are down below.
The code:
local ToTeleport = workspace.Racetrack1.ToTeleport
local Racetrack1Parts = workspace.Racetrack1:GetDescendants()
local ToTeleport
for _, part in (Racetrack1Parts) do
if part.Name == "ToTeleport" then
ToTeleport = part
end
end
racetrack1 might not have fully replicated so probably best to wait for both, i.e:
local track1 = workspace:WaitForChild("racetrack1",5);
local toTeleport = track1 and track1:WaitForChild("ToTeleport",5);
if not toTeleport then return end;
print("woop!");