How would I get a player to teleport to another place. Not a part like place. But they only get teleported if you press a gui button. For example am working on a fnaf game. And am making a lobby.
button.Activated:Connect(function()
game:GetService("TeleportService"):TeleportAsync(gameid, game.Players.LocalPlayer)
end)
am getting a error
Unable to cast value to Objects
Which line? did you define the ‘button’ and the ‘gameid’ variable?
I use a gui button not a actual button
can you show me the edited script?
Play.MouseButton1Down:Connect(function()
if Fnaf.Value == 1 then
game:GetService("TeleportService"):TeleportAsync(10873668826, game.Players.LocalPlayer)
print("Teleporting")
end
if Fnaf.Value == 2 then
print("Not out yet. Coming Soon!")
end
if Fnaf.Value == 3 then
print("Not out yet. Coming Soon!")
end
if Fnaf.Value == 4 then
print("Not out yet. Coming Soon!")
end
end)
TeleportAsync takes the placeid, and an ARRAY so just surround it with bracets. This array only accepts player instances:
:TeleportAsync(10873668826, {game.Players.LocalPlayer})
Using :Teleport
here would probably be best because it seems that you code only teleports one player. Note that TeleportService WON’T work on the client.
:Teleport(10873668826, game.Players.LocalPlayer)
Code
--Button Settings 2--
local PlayFrame = script.Parent.PlayFrame
local Play = PlayFrame.Play
local Fnaf = script.Parent.PlayFrame.Fnaf
Play.MouseButton1Down:Connect(function()
if Fnaf.Value == 1 then
game:GetService("TeleportService"):Teleport(10873668826, game.Players.LocalPlayer)
print("Teleporting")
end
if Fnaf.Value == 2 then
print("Not out yet. Coming Soon!")
end
if Fnaf.Value == 3 then
print("Not out yet. Coming Soon!")
end
if Fnaf.Value == 4 then
print("Not out yet. Coming Soon!")
end
end)
error: Invalid player to teleport. - Studio
Fire a remote event and have the server teleport the player.
Please try to come up with solutions before posting.
I found out how to fix it but am trying to teleport the player to a place. not a game.
I was wrong on this post. Turns out the client can teleport himself but not others. You can right click the place and click Copy ID:
the thing is i put the place id and then it teleports me to the same game and not the other place
You cannot teleport from studio, try loading into the real game.
I tried it but it doesnt teleport me to the other game. Only the same game even though i put the right id
then it gives me a error and kicks me out
I fixed it. Though am getting the error “That place is restricted”