✓ Accepted answer
Since there are no particular errors to you code, you will have to re-check the code using my evaluation guidelines.
1) Check whether the teleporting place is the starting place of the another main game.
Since you explicitly pointed out, "Another Game", it is assumed that the destination is a completly different game and not a precedence of the current game.
Criteria
- The precedence of the
CurrentGame does not have to be Active
- The precedence of the
OtherGame does all have to be Active
- The teleportation does not work unless you are referencing the
OtherGame's starting place.
CurrentGame := The game you are using to teleport the player.
OtherGame := The destination. MUST BE A STARTING PLACE AND ACTIVE
2) If you have checked the above criteria and the error still persists, then wait for the player to fully load.
3) Make sure that the place id you put is of the starting place id and is active. Also the place id Cannot be a string.
4) Teleportation does not work in Studio and make sure the game is actually published.
[EDIT] @Kingdom5 provided an interesting comment saying that the LocalPlayer does not need to be defined. I honestly do not believe that but you can still try it out.
[EDIT] The reason is because you are not connecting the code. We will use RemoteEvents for this.
- Insert a Remote Event in
ReplicatedStorage
- Insert
Script1 in just Workspace
- Insert
Script2 in the dialog.
local Workspace = game:GetService("Workspace")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Target = Workspace:FindFirstChild("Part")
local TeleportPlayerEvent = ReplicatedStorage:WaitForChild("TeleportPlayer")
local function TeleportPlayer (player)
if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
player.Character.HumanoidRootPart.CFrame = Target.CFrame + Vector3.new(0, 5, 0)
wait()
print("The player has been teleported")
end
end
TeleportPlayerEvent.OnServerEvent:Connect(TeleportPlayer)
local Workspace = game:GetService("Workspace")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TeleportPlayerEvent = ReplicatedStorage:WaitForChild("TeleportPlayer")
local Dialog = script.Parent
local function TeleportPlayerWhenClicked (player, choice)
if choice == script.Parent.Choice1 then
TeleportPlayerEvent:FireServer()
print("Fired Server")
end
end
Dialog.DialogChoiceSelected:Connect(TeleportPlayerWhenClicked)
Let me know if the error still persists.
7 comments
did u put the game id?
of course i did XD
If you are teleporting through a local script you do not add the player. I am not sure if the second script is a local script?
Use remote events. Connect the script two when the event is fired from the dialog and it should work.
how would I implement that into my code?
Updated the code. Check it out.
where