So I will give my code but there is a problem the teleport only triggers for that person who touches it but the iris transition effect to the whole server I need so the script triggers for only that person that touches VentBoi local TweenService = game:GetService(“TweenService”)
local tweenTime = 1
local tweenIn = TweenService:Create(script.Parent, TweenInfo.new(tweenTime), { Size = UDim2.new(0, 0, 0, 0) })
local tweenOut = TweenService:Create(script.Parent, TweenInfo.new(tweenTime), { Size = UDim2.new(8, 0, 8, 0) })
local ventDoor = game.Workspace:WaitForChild(“Ventdoor”)
local teleportCoordinates1 = Vector3.new(-411.151, 4.163, -311.605)
local teleportOrientation1 = Vector3.new(0, 90, 0) – Orientation for the first teleport
local teleportCoordinates2 = Vector3.new(-794.433, 9.753, 120.326) – Updated coordinates for the second teleport
local teleportOrientation2 = Vector3.new(0, 90, 0) – Orientation for the second teleport
local soundId = “rbxassetid://17436649761” – Sound ID for the sound effect
local cooldown = false – Cooldown flag
local function onTouched(hit)
if cooldown then return end – Exit if cooldown is active
local character = hit.Parent
local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoidRootPart and humanoid then
cooldown = true -- Set cooldown flag
-- Play the sound effect from the player's character immediately upon touching the object
local sound = Instance.new("Sound")
sound.SoundId = soundId
sound.Parent = humanoidRootPart or character:WaitForChild("Head")
sound.Volume = 10 -- Set volume to 10
sound:Play()
script.Parent.Visible = true
script.Parent.Size = UDim2.new(2, 0, 2, 0)
tweenIn:Play()
wait(tweenTime)
-- First teleport to the specified coordinates with orientation
local teleportCFrame1 = CFrame.new(teleportCoordinates1) * CFrame.Angles(math.rad(teleportOrientation1.X), math.rad(teleportOrientation1.Y), math.rad(teleportOrientation1.Z))
humanoidRootPart.CFrame = teleportCFrame1
tweenOut:Play()
wait(tweenTime)
script.Parent.Visible = false
-- Schedule the second teleport 1 second after the initial touch
delay(1, function()
-- Second teleport to the updated coordinates with orientation
local teleportCFrame2 = CFrame.new(teleportCoordinates2) * CFrame.Angles(math.rad(teleportOrientation2.X), math.rad(teleportOrientation2.Y), math.rad(teleportOrientation2.Z))
humanoidRootPart.CFrame = teleportCFrame2
-- Play the sound effect again when the iris effect triggers after the second teleport
local sound2 = Instance.new("Sound")
sound2.SoundId = soundId
sound2.Parent = humanoidRootPart or character:WaitForChild("Head")
sound2.Volume = 10 -- Set volume to 10
sound2:Play()
-- Reset and trigger the iris effect again after the second teleport
script.Parent.Visible = true
script.Parent.Size = UDim2.new(8, 0, 8, 0)
tweenIn:Play()
wait(tweenTime)
tweenOut:Play()
wait(tweenTime)
script.Parent.Visible = false
end)
-- Wait for 15 seconds before allowing the script to be triggered again
wait(5)
cooldown = false -- Reset cooldown flag
end
end
ventDoor.Touched:Connect(onTouched)