I made this GUI for teleport players to a game, but it won't work! Here are the scripts.
Server Script:
local TeleportService = game:GetService("TeleportService") local currentInstance game.ReplicatedStorage.ModEvents.TeleportPlayer.OnServerEvent:Connect(function(player, UsernameText) local suc, errormessage = pcall(function() local userId = game.Players:GetUserIdFromNameAsync(UsernameText) currentInstance, _, placeId, jobId = TeleportService:GetPlayerPlaceInstanceAsync(userId) end) if suc then TeleportService:TeleportToPlaceInstance(placeId, jobId, player) else print("There was an error teleporting player.") end end)
Local Script: (In GUI)
script.Parent.MouseButton1Click:Connect(function() local UsernameText = script.Parent.Parent.Username.Text game.ReplicatedStorage.ModEvents.TeleportPlayer:FireServer(UsernameText) end)
its pretty easy just delete your scripts and add this one to the gui
wait(1) player = game.Players.LocalPlayer button = script.Parent local debounce = false function helpme() if not debounce then debounce = true Torso = player.Character.Torso Torso.CFrame = game.Workspace.part.CFrame -- change the "part" to where ever you want player to go end end button.MouseButton1Click:connect(helpme) while true do wait() debounce = false end
try to do
local TeleportService = game:GetService("TeleportService") local currentInstance game.ReplicatedStorage.ModEvents.TeleportPlayer.OnServerEvent:Connect(function(player, UsernameText) local suc, errormessage = pcall(function() local userId = plr.UserId currentInstance, _, placeId, jobId = TeleportService:GetPlayerPlaceInstanceAsync(userId) end) if success then TeleportService:TeleportToPlaceInstance(0, player, jobId) --- repleace the 0 to your place id that you are teleporting to else print("There was an error teleporting player.") end end)