I have made a keycard-like entrance that requires the player to hold and item and touch a secret object, but instead of opening some kind of door it teleports them to a place within the same game, so it's not putting them in a different game. Here is my code:
script.Parent.Bottle.Touched:Connect(function(hit) print("touched") if hit.Parent.Name == "Key" then print("teleport") game.Workspace.Player.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(96, 2.5, 48.5)) end end)
PS, the prints are for me debugging my code. The error I get is that Player is not a member of Workspace.
Create a part in workspace named "Teleport" (Case sensitive) and use this. The key must be out and the player has to touch the object with the key out. BTW when tools are out they are parented to the character.
script.Parent.Bottle.Touched:Connect(function(hit) if hit and hit.Parent:FindFirstChild("Humanoid") and hit.Parent:FindFirstChild("Key") and hit.Parent:FindFirstChild("Key"):IsA("Tool") then print("teleported") hit.Parent.HumanoidRootPart.CFrame = game.Workspace.Teleport.CFrame * CFrame.new(0, 5, 0) end end)