I’m trying to make player teleport to other place through double clicking button in PC OS simulation, but it does not work. I tried to look at server script, but it seems there’s no errors.
ServerScript:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TeleportService = game:GetService("TeleportService")
local PLACE_ID = 88516016933703
ReplicatedStorage:WaitForChild("TeleportToHell").OnServerEvent:Connect(function(player)
local success, err = pcall(function()
TeleportService:Teleport(PLACE_ID, player)
end)
end)
Local Script:
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local sound = script.Parent:FindFirstChild("EnterSound")
if sound and sound:IsA("Sound") then
sound:Play()
end
-- UI Button Hover Effect
local function setButtonHoverEffect(button)
local originalTransparency = button.BackgroundTransparency
local originalColor = button.BackgroundColor3
button.MouseEnter:Connect(function()
button.BackgroundTransparency = 0.5
button.BackgroundColor3 = Color3.fromRGB(0, 0, 255)
end)
button.MouseLeave:Connect(function()
button.BackgroundTransparency = originalTransparency
button.BackgroundColor3 = originalColor
end)
end
-- Double-click detection and folder copy logic
local DOUBLE_CLICK_TIME = 0.3 -- seconds
-- Helper to generate a unique name for each clone (optional)
local function getUniqueCloneName(baseName, guiRoot)
local count = 1
local newName = baseName .. "_Copy" .. tostring(count)
while guiRoot:FindFirstChild(newName) do
count = count + 1
newName = baseName .. "_Copy" .. tostring(count)
end
return newName
end
-- Recursively search for a frame named folderName under parent
local function recursiveFindFrame(parent, folderName)
for _, child in parent:GetChildren() do
if child:IsA("Frame") and child.Name == folderName then
return child
end
local found = recursiveFindFrame(child, folderName)
if found then
return found
end
end
return nil
end
-- Reference to the RemoteEvent for teleporting
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local teleportEvent = ReplicatedStorage:FindFirstChild("TeleportToHell")
local function setupFileIconDoubleClick(button, guiRoot)
local lastClick = 0
button.MouseButton1Click:Connect(function()
local now = tick()
if now - lastClick < DOUBLE_CLICK_TIME then
-- Double-click detected
local folderName = button.Name .. "Folder"
local folderTemplate = nil
-- 1. Look for folder inside the button
folderTemplate = button:FindFirstChild(folderName)
-- 2. If not found, look for folder as a sibling (child of guiRoot)
if not folderTemplate then
folderTemplate = guiRoot:FindFirstChild(folderName)
end
-- 3. If still not found, search recursively under guiRoot (Desktop)
if not folderTemplate then
folderTemplate = recursiveFindFrame(guiRoot, folderName)
end
if folderTemplate and folderTemplate:IsA("Frame") then
local clone = folderTemplate:Clone()
clone.Visible = true
clone.Name = getUniqueCloneName(folderTemplate.Name, guiRoot)
clone.Parent = guiRoot
end
-- Teleport logic for HellButton
if button.Name == "HellButton" and teleportEvent then
teleportEvent:FireServer()
end
end
lastClick = now
end)
end
local function applyHoverAndDoubleClickToAllButtons(parent, guiRoot)
for _, child in parent:GetChildren() do
if child:IsA("TextButton") or child:IsA("ImageButton") then
setButtonHoverEffect(child)
setupFileIconDoubleClick(child, guiRoot)
end
applyHoverAndDoubleClickToAllButtons(child, guiRoot)
end
end
applyHoverAndDoubleClickToAllButtons(script.Parent, script.Parent)
RemoteEvent is in ReplicatedStorage how it should be.