local function N()local N=Players.localPlayer local K=N.Character if K then local N=K:FindFirstChildOfClass("\072\117\109\097\110\111\105\100")if N then N:SetStateEnabled(Enum.HumanoidStateType.RunningNoPhysics,false)if N:GetState()==Enum.HumanoidStateType.RunningNoPhysics then N:ChangeState(Enum.HumanoidStateType.Running)end local K connection=RunService.Stepped:Connect(function()if not K then local N=workspace:FindFirstChild("\080\108\097\116\102\111\114\109")if N then local o=N:FindFirstChild("\080\108\097\116\102\111\114\109")if o then K=o.PrimaryPart end end end if not K then return end if N.RootPart and N:GetState()==Enum.HumanoidStateType.Freefall then local o=N.RootPart.Position if not isVector3InBoundsOfPart(o,K)then return end local l=N.RootPart.Velocity N.RootPart.Velocity=Vector3.new(l.X,l.Y,K.Velocity.Z)end end)end end end return function(K)if connection then connection:Disconnect()connection=nil end if K=="\080\108\097\116\102\111\114\109 \080\097\110\105\099"then N()end end

local function setupPlatformMinigame()
	local localPlayer = Players.localPlayer
	local character = localPlayer.Character

	if character then
		local humanoid = character:FindFirstChildOfClass("Humanoid")
		if humanoid then
			humanoid:SetStateEnabled(Enum.HumanoidStateType.RunningNoPhysics, false)
			if humanoid:GetState() == Enum.HumanoidStateType.RunningNoPhysics then
				humanoid:ChangeState(Enum.HumanoidStateType.Running)
			end

			local platformPart

			connection =
				RunService.Stepped:Connect(
				function()
					-- The platform part may not have replicated yet, so we need to make sure it exists
					if not platformPart then
						local map = workspace:FindFirstChild("Platform")
						if map then
							local platformModel = map:FindFirstChild("Platform")
							if platformModel then
								platformPart = platformModel.PrimaryPart
							end
						end
					end

					if not platformPart then
						return
					end

					-- When the Humanoid is in Freefall it will no longer be governed by the platform's velocity
					if humanoid.RootPart and humanoid:GetState() == Enum.HumanoidStateType.Freefall then
						local rootPos = humanoid.RootPart.Position
						-- Check if the character is in bounds of the platform
						if not isVector3InBoundsOfPart(rootPos, platformPart) then
							return
						end

						local rootVelocity = humanoid.RootPart.Velocity
						humanoid.RootPart.Velocity = Vector3.new(rootVelocity.X, rootVelocity.Y, platformPart.Velocity.Z)
					end
				end
			)
		end
	end
end

return function(minigameName)
	if connection then
		connection:Disconnect()
		connection = nil
	end
	if minigameName == "Platform Panic" then
		setupPlatformMinigame()
	end
end
