So basically it just randomly shows gameplay paused after it finishes tweening/teleporting and respawns the player, it doesnt show everytime player gets tweened.
Got no clue how to fix this since i have no clue what triggers the gameplay paused.
Server script
function Teleport(Plr, Target)
local Char = Plr.Character
local humanoidRoot = Char.HumanoidRootPart
local humanoid = Char.Humanoid
local ray = RaycastParams.new()
ray.FilterDescendantsInstances = {workspace.HexMapBin}
ray.FilterType = Enum.RaycastFilterType.Include
local floorRay = workspace:Raycast((humanoidRoot.CFrame * CFrame.new(Vector3.new(0, 0, 0))).Position, Vector3.new(0, -100, 0), ray)
if floorRay then
local walkspeed = humanoid.WalkSpeed
humanoidRoot.Anchored = true
humanoid.WalkSpeed = 0
for i,v in pairs(Char:GetChildren()) do
if v:IsA("BasePart") then
v.CanCollide = false
end
end
local Portal = Rep.HexPaths.Portal:Clone()
print(floorRay.Instance, floorRay.Instance.Size.Y / 2, Portal.Size.Y / 2)
Portal.Position = floorRay.Instance.Position + Vector3.new(0, floorRay.Instance.Size.Y / 2 + Portal.Size.Y / 2, 0)
Portal.Parent = workspace.TrashBin
wait()
CameraEvent:FireClient(Plr, "Subject", Portal)
task.wait(.5)
TweenService:Create(humanoidRoot, TweenInfo.new(1, Enum.EasingStyle.Quint), {CFrame = floorRay.Instance.CFrame * CFrame.new(Vector3.new(0, -8, 0))}):Play()
local portal = Rep.HexPaths.Portal:Clone()
portal.Position = Target.Position + Vector3.new(0, Target.Size.Y / 2 + portal.Size.Y / 2, 0)
portal.Parent = workspace.TrashBin
task.delay(1.01, function()
humanoidRoot.CFrame = portal.CFrame * CFrame.new(Vector3.new(0, -10, 0))
TweenService:Create(humanoidRoot, TweenInfo.new(1, Enum.EasingStyle.Quint), {CFrame = humanoidRoot.CFrame * CFrame.new(Vector3.new(0, 16, 0))}):Play()
task.wait(1)
ToggleAll(Portal, false)
ToggleAll(Portal.Attachment, false)
ToggleAll(portal, false)
ToggleAll(portal.Attachment, false)
for i,v in pairs(Char:GetChildren()) do
if v:IsA("BasePart") then
v.CanCollide = true
end
end
humanoidRoot.Anchored = false
humanoid.WalkSpeed = walkspeed
--Debris:AddItem(Portal, 3.1)
--Debris:AddItem(portal, 3.1)
--CameraEvent:FireClient(Plr, "Subject", humanoidRoot)
end)
end
end
Local script “Camera Assign and tween”
CameraEvent.OnClientEvent:Connect(function(Event, Type)
if Event == "Shake" then
camShake:Shake(cs.Presets[Type])
elseif Event == "Subject" then
print("go")
local camera = workspace.CurrentCamera
local TweenService = game:GetService("TweenService")
local originalCameraType = camera.CameraType
local originalCameraSubject = camera.CameraSubject
camera.CameraType = Enum.CameraType.Scriptable
camera.CameraSubject = Type
wait(2)
-- Calculate the original CFrame with the current Y and the HRP position
local originalPosition = Vector3.new(HRP.Position.X, camera.CFrame.Position.Y, HRP.Position.Z)
local originalCFrame = CFrame.new(originalPosition, character:FindFirstChild("HumanoidRootPart").Position)
-- Tween smoothly back to the original orientation and position
local tween = TweenService:Create(camera, TweenInfo.new(2, Enum.EasingStyle.Quint), {CFrame = originalCFrame})
tween:Play()
-- Wait for the tween to complete before resetting the camera
tween.Completed:Wait()
-- Reset camera to follow the original subject and camera type
camera.CameraType = originalCameraType
camera.CameraSubject = originalCameraSubject
print("stop")
end
end)
Vid: