i’m trying to make a simple portal that teleports you to the “Level3” part in workspace.
it doesn’t teleport me, and doesn’t give me an error.
my script:
script.Parent.Touched:Connect(function(hit)
if game.Players:GetPlayerFromCharacter(hit.Parent)then
hit.Parent.HumanoidRootPart.CFrame = game.Workspace.Level3.CFrame
end
end)
my error:
Level3 is not a valid member of Workspace "Workspace" - Server - Script:3
thanks
Can you show the explorer? You will need to navigate through the workspace until you reach the part.
So if you have a folder inside workspace and the folder has a part, to reach that part you will need to do game.Workspace.Folder.Part and not game.Workspace.Part
local function FindDescendant(Inst, Obj)
if Inst:FindFirstChild(Obj) then
return Obj
else
for _, v in pairs(Inst:GetDescendants()) do
if v.Name == Obj then
return v.Parent:FindFirstChild(Obj)
else
return false
end
end
end
local Level3 = FindDescendant(workspace, "Level3")
Try changing It Like This.
You may want to use Head Instead of HumanoidRootPart.
Or you can just use PrimaryPart.
local Level3Part = workspace:WaitForChild("Level3")
script.Parent.Touched:Connect(function(hit)
if game.Players:GetPlayerFromCharacter(hit.Parent)then
hit.Parent.Head.CFrame = Level3Part.CFrame
end
end)
This may be a problem on a not loaded part as well.
Hope It helped.