I have a script so when a player clicks a button, he gets teleported to another game. Whenever I test it, I get nothing. No error, nothing in the output. I tried to run the game in roblox itself but still nothing. My code:
local tp = game:GetService("TeleportService") local m = require(game.ReplicatedStorage.PlaceIDs) script.Parent.MouseButton1Click:Connect(function() tp:Teleport(m.tp1, game.Players.LocalPlayer) end)
Whenver I print the "m.tp1" it gives me the id of the game, so I don't know what I am doing wrong.
Hmm, I don't see what you're doing wrong. I'm pretty sure you would just set the localplayer and the placeid as an individual variable, because for some reason, sometimes I have to make a variable, for the script to work. Try using this script:
local TeleportService = game:GetService("TeleportService") --gets teleport service local Module = require(game.ReplicatedStorage.PlaceIDs) --requires the placeids module local Player = game.Players.LocalPlayer --gets the localplayer as a player variable script.Parent.MouseButton1Click:Connect(function() --event for when your gui is clicked local TP1 = Module.TP1 --reference variable for TP1 TeleportService:Teleport(TP1, Player) --teleports the player, passing the placeid, and the localplayer variable. end)
Also, note that you can't use teleportservice in studio, so make sure you test it out in the game.
Hopefully, the variables should make it work. I hope I helped you, and have an awesome day!