I'm trying to teleport between places and it is coded for when a, for example, part it's not clicked but your character touches it and I'm doing this on a screen GUI text button and i have a script inside of that heres the script
function parentPressed()
local TeleportService = game:GetService("TeleportService")
local placeID_1 = 4944349183
local placeID_2 = 4896092768
local function onPartTouch(otherPart)
local player = game.Players:GetPlayerFromCharacter(otherPart.Parent)
if player then
TeleportService:Teleport(placeID_1, player)
end
end
script.Parent.touched:Connect(onPartTouch)
local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
-- Is this player following anyone?
local followId = player.FollowUserId
-- If so, find out where they are
if followId and followId ~= 0 then
local success, errorMessage, placeId, jobId = pcall(function()
return TeleportService:GetPlayerPlaceInstanceAsync(followId)
end)
if success then
-- Teleport player
TeleportService:TeleportToPlaceInstance(placeId, jobId, player)
end
else
warn("Player " .. player.UserId .. " is not following another player!")
end
end)
end
script.Parent.MouseButton1Down:connect(parentPressed)

1 comment
well if you want to make a button clickable on gui you use (1)local button = script.Parent (2)button.MouseButton1Click:Connect(function() script goes inside end)