Yes let me elaborate.
Both buttons trigger the same event, however they pass different place IDs to teleport to.
I know the button is working, because it still triggers a GUI to appear telling the user they are being teleported (controlled by a separate script.)
However for some reason it seems the server isnt being told that the button is being pressed because TeleportService isnt being used for some reason.
I get absolutely 0 errors and no prints, unlike the first button.
Here is the code to each button. Like I stated before they are identical in every way except the place ID that is being carried over.
Button 1 (Localscript inside of button)
-- LocalScript inside TextButton
local button = script.Parent
local teleportService = game:GetService("TeleportService")
local player = game.Players.LocalPlayer
-- Print to debug
button.MouseButton1Click:Connect(function()
print("Button clicked!") -- Debug print statement
local remoteEvent = game.ReplicatedStorage:FindFirstChild("TeleportRequest")
if remoteEvent then
remoteEvent:FireServer(18779044642) -- Replace with your target place ID
print("Teleport request sent.") -- Debug print statement
else
print("TeleportRequest RemoteEvent not found.") -- Debug print statement
end
end)
Button 2 (Localscript inside of button)
local button = script.Parent
local teleportService = game:GetService("TeleportService")
local player = game.Players.LocalPlayer
-- Print to debug
button.MouseButton1Click:Connect(function()
print("Button clicked!") -- Debug print statement
local remoteEvent = game.ReplicatedStorage:FindFirstChild("TeleportRequest")
if remoteEvent then
remoteEvent:FireServer(129529971996782) -- Replace with your target place ID
print("Teleport request sent.") -- Debug print statement
else
print("TeleportRequest RemoteEvent not found.") -- Debug print statement
end
end)
Here is the Serverscript that fires when the remoteevent (teleport event) is fired.
local teleportService = game:GetService("TeleportService")
local replicatedStorage = game:GetService("ReplicatedStorage")
local teleportRequest = replicatedStorage:WaitForChild("TeleportRequestInteractive")
teleportRequest.OnServerEvent:Connect(function(player, targetPlaceId)
print("Teleport request received for Place ID:", targetPlaceId)
if player and targetPlaceId then
teleportService:Teleport(targetPlaceId, player)
else
warn("Invalid player or Place ID.")
end
end)
The first button works perfectly as expected, however the second button does not and gives no errors. Even when I am expecting it to tell me I cant teleport to another place in studio, which leads me to believe that the server for some reason is not being told that the player is trying to teleport