Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I made a teleport GUI but it wont work, can someone help?

Asked by 4 years ago

I made this GUI for teleport players to a game, but it won't work! Here are the scripts.

Server Script:

01local TeleportService = game:GetService("TeleportService")
02local currentInstance
03 
04game.ReplicatedStorage.ModEvents.TeleportPlayer.OnServerEvent:Connect(function(player, UsernameText)
05    local suc, errormessage = pcall(function()
06        local userId = game.Players:GetUserIdFromNameAsync(UsernameText)
07        currentInstance, _, placeId, jobId = TeleportService:GetPlayerPlaceInstanceAsync(userId)
08    end)
09    if suc then
10        TeleportService:TeleportToPlaceInstance(placeId, jobId, player)
11    else
12        print("There was an error teleporting player.")
13    end
14end)

Local Script: (In GUI)

1script.Parent.MouseButton1Click:Connect(function()
2    local UsernameText = script.Parent.Parent.Username.Text
3    game.ReplicatedStorage.ModEvents.TeleportPlayer:FireServer(UsernameText)
4end)

2 answers

Log in to vote
0
Answered by
adolof -8
4 years ago

its pretty easy just delete your scripts and add this one to the gui

01wait(1)
02player = game.Players.LocalPlayer
03button = script.Parent
04local debounce = false
05 
06function helpme()
07 if not debounce then
08 
09 debounce = true
10 Torso = player.Character.Torso
11 Torso.CFrame = game.Workspace.part.CFrame -- change the "part" to where ever you want player  to go
12 
13 end
14end
15button.MouseButton1Click:connect(helpme)
16 
17while true do wait()
18debounce = false
19end
Ad
Log in to vote
0
Answered by 4 years ago

try to do

01local TeleportService = game:GetService("TeleportService")
02local currentInstance
03 
04game.ReplicatedStorage.ModEvents.TeleportPlayer.OnServerEvent:Connect(function(player, UsernameText)
05    local suc, errormessage = pcall(function()
06        local userId = plr.UserId
07        currentInstance, _, placeId, jobId = TeleportService:GetPlayerPlaceInstanceAsync(userId)
08    end)
09    if success then
10        TeleportService:TeleportToPlaceInstance(0, player, jobId) --- repleace the 0 to your place id that you are teleporting to
11    else
12        print("There was an error teleporting player.")
13    end
14end)

Answer this question