I am trying to send the player that clicked the button to a game but nothing happens. I have tested many things and nothing is working,
script.Parent.MouseButton1Click:Connect(function(player)
local telePart = script.Parent
local TeleportService = game:GetService('TeleportService')
local placeID = 7071609084
local canTeleport = true
--local name = player.parent.name
--local player1 = game.Players[name]
if player and canTeleport then
canTeleport = false
TeleportService:Teleport(placeID, player)
end
end)
Try a proximity prompt. The might work.
Is this to get a SurfaceGui to teleport the player to another game? Is it a local or server script?
it is a server script and it is a gui that is on screen
Alright so, as far as I’m aware, MouseButton1Click doesn’t generally give a player. For this you’d likely be better off using a LocalScript in StarterPlayerScripts.
I’ve written up something that should work
local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local TeleportPart = workspace:WaitForChild("TeleportPart")
local PlaceID = 7071609084
local CanTeleport = true
TeleportPart.SurfaceGui.TeleportButton.MouseButton1Click:Connect(function()
TeleportService:Teleport(PlaceID)
CanTeleport = false
end)
Give this a try. Do keep in mind, localscripts don’t work in workspace which is why we’re using StarterPlayerScripts.
Quick edit, make sure “Allow Third Party Teleports” is on, this is located in Game Settings under the Security tab.
1 Like