Gameplay Paused when tweening the player and camera

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:

1 Like

It’s streaming that causes it, you can disable it via workspace.StreamingEnabled

what exactly does streamingenabled does

It unloads models that are far away from the player

it will impact performance right?

Having it enabled will reduce memory impact because it unloads models that are far away, but if you don’t need the behaviour then you can disable it. If you do need it, models have a ModelStreamingMode property that can be used to change some streaming behaviours for that model, you can also disable the pause via workspace.StreamingIntegrityMode

You don’t have to necessarily disable it like the other guy says, it’s usually used to optimize the client for big maps. you can change the properties of it instead:

I recommend watching this video:

You can also use the documentation as a reference:

1 Like

also do anyone have any idea why the player dies at the same moment when the gameplay paused shows?

I believe it may be due to the tweening of the player. I’m not sure why you’d have to tween for a simple teleport script.

i just want a smooth dropping and coming out of the portal scene, those are the only times i tween the player. but the thing i dont understand is that it rhappens on random teleport, it doesnt happen after each teleport.