local TweenService = game:GetService("TweenService")
local Pad = game.Workspace.TeleportLounge2
script.Parent.Touched:Connect(function(hit)
local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
if Player then
local CurrentlyTeleporting = Player.Character:FindFirstChild("CurrentlyTeleporting")
if not CurrentlyTeleporting then return end
if not CurrentlyTeleporting.Value then
CurrentlyTeleporting.Value = true
-- Freeze the player
local humanoid = Player.Character:FindFirstChildOfClass("Humanoid")
if humanoid then
humanoid:ChangeState(Enum.HumanoidStateType.Physics)
end
-- Wait for 1.5 seconds before teleporting
wait(0.1)
-- Define the target CFrame for the teleport
local targetCFrame = Pad.CFrame + Vector3.new(0, 5, 0)
-- Define the tween info
local tweenInfo = TweenInfo.new(
3, -- Time for the tween to complete (changed to 5 seconds)
Enum.EasingStyle.Quad, -- Easing style
Enum.EasingDirection.Out -- Easing direction
)
-- Create the tween
local teleportTween = TweenService:Create(Player.Character.HumanoidRootPart, tweenInfo, {CFrame = targetCFrame})
-- Play the tween
teleportTween:Play()
-- Wait for the tween to complete
teleportTween.Completed:Wait()
-- Restore player's movement
if humanoid then
humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
end
wait(3) -- Optional delay after teleporting
CurrentlyTeleporting.Value = false
end
end
end)
This wont work it used to work but suddenly broke and idk when